preprocessor directive #warning

My Helpfile says the following:


-----


The #warning Conditional Directive

The #warning directive takes a string as an argument and produces a warning message at compile-time. Warnings produced by this directive are displayed as normal compiler warnings.


Like the #error directive, this directive is most useful for detecting pre-defined constraints and inconsistencies during preprocessing of a source file.


Syntax


#warning messagestring


The message string identifier shown above indicates the warning message to be displayed. The following example illustrates use of the #warning directive:


#if !TRACING

#warning This interface has not been completely tested yet!

#endif


When the warning above is encountered, the following line will be output:


#warning 'This interface has not been completely tested yet!' (J5500)


-----


But when I use #warning, I always get an error undefined preprocessor directive.

#error works fine, though.


I use MS Visual Studio (VC)


Comments

  • #warning is part of VJ++ not VC++. MSDN is so messed up!


    If you want to do the same in VC, you can do:

    #pragma message( "This will go to the Build window" )


    Tnx


    : My Helpfile says the following:


    : -----


    : The #warning Conditional Directive

    : The #warning directive takes a string as an argument and produces a warning message at compile-time. Warnings produced by this directive are displayed as normal compiler warnings.


    : Like the #error directive, this directive is most useful for detecting pre-defined constraints and inconsistencies during preprocessing of a source file.


    : Syntax


    : #warning messagestring


    : The message string identifier shown above indicates the warning message to be displayed. The following example illustrates use of the #warning directive:


    : #if !TRACING

    : #warning This interface has not been completely tested yet!

    : #endif


    : When the warning above is encountered, the following line will be output:


    : #warning 'This interface has not been completely tested yet!' (J5500)


    : -----


    : But when I use #warning, I always get an error undefined preprocessor directive.

    : #error works fine, though.


    : I use MS Visual Studio (VC)





  • NT = NO TEXT


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories