fakedrake
fakedrake

Reputation: 6856

Clang preprocessor to strip comments from C++ files

I know the gcc preprocessor can use -fpreprocessed to only remove comments from a file and leave the rest untouched but how can I do the same with clang?

Upvotes: 8

Views: 2540

Answers (1)

Brad Robinson
Brad Robinson

Reputation: 46797

As decribed here, use -E (and probably -P, to exclude line number info)

clang -E -P <inputfile> -o <outputfile>

(although this will do more than just remove comments - it'll also expand macros etc...)

Upvotes: 2

Related Questions