Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 575
fakedrake Avatar asked Mar 09 '15 14:03

fakedrake


1 Answers

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...)

like image 163
Brad Robinson Avatar answered Oct 14 '22 01:10

Brad Robinson