If I had a project structured like this...
a.cpp b.cpp c.cpp
...and I wanted to compile a.cpp and b.cpp with one set of compiler options, and c.cpp with another set, how would I do that?
If I had a project structured like this...
a.cpp b.cpp c.cpp
...and I wanted to compile a.cpp and b.cpp with one set of compiler options, and c.cpp with another set, how would I do that?
I think the easiest way would be to separate them into different projects based on the compiler options you require, and then set up your dependencies appropriately to link them all into your final executable.
Depending on what options you need, exactly, you might be able to use the corresponding pragmas in the source code - e.g. #pragma optimize
.
That said, be warned that, with some compiler options, files compiled with different ones may be binary incompatible - for example, /vmb
vs /vmg
.
One option is to create a new group (or 'filter' in VS.Net parlance) to make it obvious which group of files are affected by the particular settings. It can be something of a maintenance headache otherwise as it's difficult to see which files have got different settings without opening the .vcproj file in a text editor.
The simplest way (although not the easiest way to maintain) is to right click on your source file in Solution Explorer and select "Properties". From there you can customize your compiler options for the selected source file.