Question

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.

Was it helpful?

Solution 2

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top