This is a mirror of official site: http://jasper-net.blogspot.com/

How do I print non-error messages during compilation?

| Monday, January 16, 2012
Commenter Worf remarked, "My one wish is that #warning would be supported."

I always find it interesting when people say "I wish that Microsoft would stop following standards," since the #warning directive is nonstandard.

The Microsoft C/C++ compiler implements the feature in a method compatible with the standard, namely via a #pragma directive.

#pragma message("You really shouldn't be doing that.")

If you want to warn people away from deprecated functionality, you can use the #pragma deprecated() directive or the even more convenient (but more standards-troublesome) __declspec(deprecated) declaration specifier. The declaration specifier is much more convenient than the preprocessor directive because you can use it in a macro, and you can attach it to specific overloads of a function. (It's also more standards-troublesome because, while it is still permitted by the standard because it begins with a double-underscore, it is also not required to be ignored by compilers which do not understand it.)

Read more: The old new thing
QR: 10256146.aspx

Posted via email from Jasper-net

0 comments: