Jump to content

Introspection: Difference between revisions

Added C++
No edit summary
(Added C++)
Line 296:
doing this kind of check in a shell script and defining symbols
such as HAVE_ABS which ''can'' be checked by the preprocessor.
=={{header|C++}}==
Identifying the version of the C++ standard used by the compiler in C++ is syntactically very similar to the way of checking the C standard version (also seen on this page).
 
<lang cpp>#if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
// ...
#endif</lang>
 
As in C, the introspective capabilities of C++ are very limited.
=={{header|C sharp|C#}}==
There has to be some caveats made with C#. There are no truly "global" variables - just publicly exported ones from individual classes/types. I chose to make a couple of public static variables in my program's class. Also, the "version" of the compiler is difficult to impossible to get at. There are no predefined compiler constants that can be compared against as in C/C++ but then again, it's hardly the thing that counts in C#. What really counts is the version of .NET and the framework you're working with since that determines what C++ features you can use and the various calls that can be made. Consequently, I check the .NET version to make sure it's past 4.0 and exit if not.
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.