I am working with a primitive C Parser that does not handle the Preprocessor directive.
I can preprocess most of the header with the -E switch without problem.
Lately I found cases when attribute and align are present.
I tried to get rid of them with this tweak:
gcc -D "aligned(ARGS)" \
-D "__align__(ARGS)" \
-D "__attribute__(ARGS)" \
-E /usr/local/include/fancyheader.h
Update:
But without success, example:
struct __attribute__((aligned(16))) long4
{
long int x, y, z, w;
};
The above statements is transformed to, with开发者_开发百科 that "1" pending around
struct 1 long4
{
long int x, y, z, w;
};
Who knowzs the correct way to get rid of the __align__ and __attribute__ extensions ?
What happens when you use -D "aligned(ARGS)="
?
The preprocessor assigns the value 1
to all macros defined on the command line without specifying a replacement list. For instance, if you compile with -DFOO:
std::cout << FOO << std::endl;
will print 1
. If you want to explicitly set the macro replacement list to be empty use -DFOO=
(or in your case -D__align__(x)=
.
How about un-defining all built-in and pre-defined macros with the -U
option, and then creating new definitions with the -D
option?
精彩评论