tags:

views:

97

answers:

4

In gcc I can do compile-time warnings like this:

#if !defined(_SOME_FEATURE_)
   #warning _SOME_FEATURE_ not defined-- be careful!
#endif

But in Visual Studio this doesn't work. Is there an alternative syntax for #warning?

A: 

#pragma WEIRD_VALUES_HERE

is the way I've always seen it done. M$ probably has the pragmas on their site somewhere.

Michael Dorgan
VS `#pragma` Reference: http://msdn.microsoft.com/en-us/library/d9x1s805%28v=VS.80%29.aspx
Nick T
+3  A: 

About the closest equivalent would be #pragma message, or possibly #error (the latter stops compilation, the former just prints out the specified error message).

Jerry Coffin
+1 messages seems to be it.
Tom
+1  A: 

Use #pragma message("Some message")

Jasper Bekkers
A: 

Another thought is template style compile time asserts. Boost has a whole selection of these if you are wanting to check compile time code errors.

Michael Dorgan
The question asks for *warnings*.
Georg Fritzsche