Single source with multiple objects

Single source with multiple objects I use MSVS 2010 and I have a C ++ source file that should compile into 2 object files. The difference between these compilations is "#define UNICODE" for one of them, but not for the other. I cannot (and do not want) to use templates for this.

I am currently using 3 source files for this in my project. The actual source is excluded from the assembly, while the other 2 are wrappers around it. Like this:

file = wrap-UNICODE.cpp

#ifndef UNICODE
#define UNICODE
#endif

#include "actual-source.cpp"
// eof

file = wrap-ANSI.cpp

#ifdef UNICODE
#undef UNICODE
#endif

#include "actual-source.cpp"
// eof

When using makefiles, I can easily avoid using shell bags by using different output switches. My question is: I would like to know if (and how) I can do this directly in the MSVS project.

+3
4

, , . MS Visual Studio 2005 Standard Edition; (, , , , , , :)).

. ( stuff.vcproj ) , :

<File
    RelativePath=".\actual-source.cpp"
    >
</File>
<File
    RelativePath=".\actual-source.cpp"
    >
</File>

MSVS. (Ctrl + Alt + L ); . (Alt + F7 ) (, ).

: " ", " " ( ) (, actual-source-unicode; MSVS .obj ), , obj , .

+1

AFAIK . ( ).

, . - .

0

Visual Studio _UNICODE , .

0

( ), Batch Build? .

0

Source: https://habr.com/ru/post/1776478/


All Articles