rreichel
rreichel

Reputation: 823

Preprocess C-Code with gcc or cpp without resolving macros

Does there exists a flag that I can pass to one of these preprocessors that causes the preprocessor to not resolve any macros in the code? I"m trying to use it just to concatenate any included header files into one file. Thanks!

Upvotes: 1

Views: 123

Answers (2)

Mike Kinghan
Mike Kinghan

Reputation: 61202

From the manual

-fdirectives-only
    When preprocessing, handle directives, but do not expand macros.

Read the full entry for complete details.

Add the -P option to suppress #line directives, e.g.

g++ -E -P -fdirectives-only ... file.cpp

or:

cpp -P -fdirectives-only ... file.cpp

Upvotes: 4

Artur Opalinski
Artur Opalinski

Reputation: 1092

AFAIK there is no such flag. If you only want to concatenate header files - go ahead and write a short program for this.

You may anyway need sch program as the preprocessor does more than including headers and extending macros. It is also responsible e.g. for concatenating string literals, so e.g. "This""And""That" is turned into "ThisAndThat". So you will get some unexpected changes in your sources anyway.

Upvotes: 0

Related Questions