Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio from command line generates warnings; IDE does not

I'm using Visual Studio 2005 (32-bit) on a Windows XP system. I've got a C++ project that I build from the command line (in a batch file) that uses devenv.exe to launch the build. Here's an example of how it gets launched:

{path_to_devenv.exe} my_solution.sln /rebuild "Debug|Win32" /out my_logfile.txt

Within the code for this project, we use a few pragma statements to disable some extraneous warnings that we don't want to see:

#pragma warning ( disable : 4521 4522 )
// Some code here
#pragma warning ( default : 4521 4522 )

When the project is built in the debug configuration from the IDE, these warnings do not show up in the build output. When the same project is built from the command line, the warnings do show up in our log file (which we specified with the /out command line parameter). When building in release, the warnings do not show up in either case.

Is there something different about driving VS 2005 through devenv.exe that causes the pragma to be ignored in the debug case? Why should these warnings show up in one world and not the other?

like image 217
Jonah Bishop Avatar asked Dec 29 '25 01:12

Jonah Bishop


1 Answers

Frankly the only reason I can see this happening is when the pragmas aren't seen.

Check

  • the build configuration (are you building Debug|Win32 from within the IDE too?)
  • and especially the include paths (are they the same; perhaps see whether the environment contains other settings)
  • are you doing a full rebuild from within the IDE? I wouldn't rule out that you usually don't see the warnings in the IDE, because you usually do an incremental build and the related sources don't need to be built. Check whether you get the same errors when doing a full rebuild in the IDE

If you are desperate for clues, you can always keep the result of preprocessing using both variants and compare them. The 'keep preprocessed source' option is hidden somewhere under the 'Preprocessor' C++ build settings.

Good luck

like image 181
sehe Avatar answered Dec 31 '25 15:12

sehe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!