printing a warning with the preprocessor

S

Shea Martin

I would like to issue a warning with the preprocessor:

#ifdef _A_DEFINE && OTHER_DEFINE
#print "_A_DEFINE and OTHER_DEFINE cannot both be defined"
#print "OTHER_DEFINE will be undefined for you"
#endif

I realize that the above example may created some unexpected behavoir,
but the situation in which I am actually using it makes sense.

I have tried using #error "my message", but this causes the CPP to
abort, I just want a warning printed.

I also tried #warn "my message", but this is not recognized my Sun's CPP.

Thanks,

~S
 
V

Victor Bazarov

Shea said:
I would like to issue a warning with the preprocessor:

#ifdef _A_DEFINE && OTHER_DEFINE
#print "_A_DEFINE and OTHER_DEFINE cannot both be defined"
#print "OTHER_DEFINE will be undefined for you"
#endif

I realize that the above example may created some unexpected behavoir,
but the situation in which I am actually using it makes sense.

I have tried using #error "my message", but this causes the CPP to
abort, I just want a warning printed.

I also tried #warn "my message", but this is not recognized my Sun's CPP.

Well, it's a good hint for you to RTFM on your compiler, isn't it?

Some compilers have '#pragma message' but I don't know about Sun's. Like
I said, RTFM.

V
 
S

Shea Martin

Victor said:
Well, it's a good hint for you to RTFM on your compiler, isn't it?

Some compilers have '#pragma message' but I don't know about Sun's. Like
I said, RTFM.

V
Well I RTFM for CPP(2) and for for the compiler's pragma-appendix before
I posted, so that I wouldn't be condescended upon...

Anyway, #pragma message is not supported. Maybe I am WTFD to figure it out.

~S
 

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

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top