In C# we can use #warning
to show a warning in error window.
In Visual C++, #pragma message
is something like that, but it just a outputs a message not a warning.
In C++ (Windows, Visual Studio, MSVC) is there a way to show a warning to user purposely?
I tried #warning DEBUG is defined
which works in some other compilers, but not MSVC.
It gives me this error:
error C1021: invalid preprocessor command 'warning' AecProject stdafx.h 49
In gcc, #warning
works fine in the way that you would expect (i.e. like #error
it outputs a message at compile time, but does not cause the compilation to terminate)
It seems that #warning
is not available in Visual Studio. Instead you can try experimenting with #pragma warning
although this does not emit a message but allows the settings for compiler messages to be altered. The syntax for this is more complex and can be found here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With