How can you tell whether a program was compiled using C versus C ? Ans. The ANSI standard for the C language defines a symbol named __cplusplus that is defined only when you are compiling a C program. If you are compiling a C program, the __cplusplus symbol is undefined. Therefore, you can check to see whether the C compiler has been invoked with the following method: #ifdef __cplusplus /* Is __cplusplus defined? */ #define USING_C FALSE /* Yes, we are not using C */ #else #define USING_C TRUE /* No, we are using C */ #endif When the preprocessor is invoked, it sets USING_C to FALSE if the __cplusplus symbol is defined. Otherwise, if __cplusplus is undefined, it sets USING_C to TRUE. Later in your program, you can check the value of the USING_C constant to determine whether the C compiler is being used. - Study24x7
Social learning Network
27 Mar 2023 11:54 AM study24x7 study24x7

How can you tell whether a program was compiled using C versus C++? Ans. The ANSI standard for the C language defines a symbol named __cplusplus that is defined only when you are compiling a C++ program. If you are compiling a C program, the __cplusplus symbol is undefined. Ther...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles