meta-pragma

O

Old Wolf

I have some code that is to compile on two different compilers.
Each compiler has a different syntax for a required #pragma
statement (OT, but the pragma's purpose is to identify the
TU's data so the linker can put it where I want it).

Currently I am writing:

#if (defined FOO_COMPILER)
# pragma FOO
#elif (defined BAR_COMPILER)
# pragma BAR
#endif

in every .c file. This would be even worse if there were more
compilers to support. I would prefer to have just one line in
every .c file, eg:

#pragma THE_PRAGMA

and in a header file:

#if (defined FOO_COMPILER)
# define THE_PRAGMA FOO
#elif (defined BAR_COMPILER)
# define THE_PRAGMA BAR
#endif
but that syntax isn't accepted. Is there some way of doing
what I want?
 
B

Ben Pfaff

Old Wolf said:
I would prefer to have just one line in
every .c file, eg:

#pragma THE_PRAGMA

and in a header file:

#if (defined FOO_COMPILER)
# define THE_PRAGMA FOO
#elif (defined BAR_COMPILER)
# define THE_PRAGMA BAR
#endif
but that syntax isn't accepted. Is there some way of doing
what I want?

How about this? Put
#if (defined FOO_COMPILER)
# pragma FOO
#elif (defined BAR_COMPILER)
# pragma BAR
#endif
in pragma.h, and then put
#include "pragma.h"
in every .c file at the point required.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top