Clark Gaebel
Clark Gaebel

Reputation: 17948

File-specific compilation options in Visual Studio 2008

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?

Upvotes: 0

Views: 282

Answers (4)

R Samuel Klatchko
R Samuel Klatchko

Reputation: 76541

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.

Upvotes: 0

the_mandrill
the_mandrill

Reputation: 30842

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.

Upvotes: 0

Pavel Minaev
Pavel Minaev

Reputation: 101565

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.

Upvotes: 0

LeopardSkinPillBoxHat
LeopardSkinPillBoxHat

Reputation: 29421

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.

Upvotes: 2

Related Questions