Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep comments in preprocessor i file

We want to use the preprocessor output file (.i file ) for further use, especially the comments.
For that, we use the /PREPRINT (or /PP) command line switch.
The problem is that the KEIL compiler (C166) deletes any comments.

Q: Is it possible to keep comments in the .i file?

Additional research:
The Microsoft compiler does this with the /P command line switch.
But they has /C to keep comments.

like image 635
joe Avatar asked Jun 03 '13 14:06

joe


2 Answers

You can use

gcc -E -CC file.c

It keeps all the comments, including the ones in the .h files that may have been included by C file.

like image 183
Arun Taylor Avatar answered Sep 21 '22 19:09

Arun Taylor


I turns out that the C166 Keil compiler supports also the /C compiler switch. This switch is not available through the IDE and is not documented.
To use it, we had to write a batch file that contains the /C switch and run the compiler a second time to create the .i file.

It also turns out that all of the compilers we use has this switch (Mircosoft, and as Arun Taylor mentioned, the GCC compiler). So we are able to use the commented .i file from every compiler.

like image 43
joe Avatar answered Sep 18 '22 19:09

joe