What I mean is, in each of my source files I have to insert #define NOGDI to stop windows.h from including GDI defines (since it's BITMAP define conflicts with mine).
e.g.
#define NOGDI
#include <windows.h>
Unfortunately, I have to do this in every seperate source file which includes windows.h, which I do not want to do.
I am using Visual Studio 2005, is there any way I can set it to #define something globally? (i.e. in all of the source files).
Project Settings -> C/C++ -> Preprocessor -> Preprocessor definitions
Here you can define symbols that are applied globally to all source code in your project.
I had set up the needed define for whole project, as described, in
Project Settings -> C/C++ -> Preprocessor -> Preprocessor definitions
But nevertheless this didn't work!
Eventually it turned out that problem was in checked NoInherit checkbox,
"Inherit from parent or project defaults"
In defines' line of Preprocessor Definitions Dialog it's seen as:
WIN32;_DEBUG;_WINDOWS;_MBCS;$(NoInherit)
Checked the thing back and the define finally recognized.
For VS2015 I edited the .vcxproj
file and added a section such as this:
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>MY_VARIABLE=SOMETHING</PreprocessorDefinitions>