[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


Using an Identifier After #endif

(K&R, §A12.5) The C compiler can accept an identifier token after #endif and #else. This extension helps you match an #endif statement with its corresponding #if, #ifdef, or #ifndef statement, as shown here:


#ifdef __MWERKS__
#    ifndef __cplusplus
        /*
         * . . . 
         */
#    endif __cplusplus
#endif __MWERKS__

To turn this feature on, turn off the ANSI Strict setting in the C/C++ Language Panel. If the ANSI Strict setting is on, then this extension to standard C is disabled.

See also: "ANSI Strict."


TIP

If you turn on the ANSI Strict option (disabling the extension), you can still use the same idea to help you match your #ifdef and #endif directives. Simply put the identifiers into comments, as in the following example.

#ifdef __MWERKS__
#    ifndef __cplusplus
        /*
         * . . . 
        */
#    endif /* __cplusplus */
#endif /* __MWERKS__ */


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 17, 2000