Community
Participate
Working Groups
Build Identifier: 20110916-0149 Using Visual C++ Tool Chain Preprocessor symbol __STDC__ always defined although /Za is not given __STDC__ is only defined in MS VC if compiler switch /Za is given and it isn't a C++ file. Reproducible: Always Steps to Reproduce: 1. Create a C or C++ project using Visual C++ Tool Chain, don't set compiler switch /Za 2. Create a new file with following content: //#undef __STDC__ #ifdef !__STDC__ #define TEST "TEST" <-- this code is shown as inactive #endif 3. uncomment "#undef __STDC__" makes TEST macro available
Currently it is defined by cdt parser in CPreprocessor. But it should be probably defined by scanner discovery where it could inspect toolchain options. If so I think we should remove the macro definition from CPreprocessor class.
I don't mind removing the builtin definition in the preprocessor. However, we may make the situation worse for other users that then miss the definition for __STDC__. I think we first need to provide the support for scanner configuration for the microsoft compiler (or do we already have that?) and only afterwards remove the predefined value for __STDC__.
Fixed in commit http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=48d5341bf7fdfd5b11540e032ed2dc969e8c32d1.
(In reply to Nathan Ridge from comment #3) > Fixed in commit > http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/ > ?id=48d5341bf7fdfd5b11540e032ed2dc969e8c32d1. Please ignore that, I meant to post that to a different bug.
New Gerrit change created: https://git.eclipse.org/r/150322
Gerrit change https://git.eclipse.org/r/150322 was merged to [master]. Commit: http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=4e16631f30de08444342b0ad6622cfcf3cd39fd4
(In reply to Markus Schorn from comment #2) > I don't mind removing the builtin definition in the preprocessor. However, > we may make the situation worse for other users that then miss the > definition for __STDC__. > I think we first need to provide the support for scanner configuration for > the microsoft compiler (or do we already have that?) and only afterwards > remove the predefined value for __STDC__. We don't have a scanner configuration for MSVC yet but instead use the CompilerType in GPP/GCC Scanner configuration to decide whether or not to add __STDC__. We also use CompilerType so set other MSVC specific keywords so it is trivial to add another macro. Other scanner configurations not extending GPP/GCCScannerExtensionConfiguration are changed to add __STDC__ for minimizing client impact. Having MSVC have its own scanner configuration and language will be a better solution but can be done separately. If anyone knows how to do that based on toolchain that would be helpful! We are also missing the case where files are compiled as C and /Za is used, but that should be much less common. See bug 551758.