diff --git a/examples/Hello/Hello.h b/examples/Hello/Hello.h index 8e02cde4..d1b2bd41 100644 --- a/examples/Hello/Hello.h +++ b/examples/Hello/Hello.h @@ -2,6 +2,10 @@ #include #include +#ifndef WIN32 + #error "Generator should understand defines as well" +#endif + class Hello { public: diff --git a/examples/Hello/premake4.lua b/examples/Hello/premake4.lua index 65279852..147e5b3c 100644 --- a/examples/Hello/premake4.lua +++ b/examples/Hello/premake4.lua @@ -9,10 +9,10 @@ solution "Hello" debugdir ( "./bin/") configuration "Debug" - defines { "DEBUG" } + defines { "DEBUG", "WIN32" } configuration "Release" - defines { "NDEBUG" } + defines { "NDEBUG", "WIN32" } flags { "Optimize" } project "Hello" @@ -36,7 +36,7 @@ project "Hello" buildrule { description = "Compiling $(InputFile)...", commands = { - '..\\..\\bin\\generator.exe -vs=10 -ns=CppCsBind -outdir=CppCsBind -I. hello.h', + '..\\..\\bin\\generator.exe -D=WIN32 -vs=10 -ns=CppCsBind -outdir=CppCsBind -I. hello.h', }, outputs = { "CppCsBind\\hello_wrapper.cpp" } } diff --git a/src/Generator/CodeGenerator.cs b/src/Generator/CodeGenerator.cs index 5a145729..4a5779df 100644 --- a/src/Generator/CodeGenerator.cs +++ b/src/Generator/CodeGenerator.cs @@ -44,8 +44,13 @@ namespace Cxxi { Library = library, Verbose = false, +<<<<<<< HEAD IncludeDirs = options.IncludeDirs FileName = file, +======= + IncludeDirs = options.IncludeDirs, + Defines = options.Defines, +>>>>>>> 7304ce4... Wire -Ddefine support. toolSetToUse = options.toolset2use }; diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index 6ef10c23..301dbf01 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -208,6 +208,12 @@ void Parser::Setup(ParserOptions^ Opts) C->getHeaderSearchOpts().AddPath(s, frontend::Angled, true, false, true); } + for each(System::String^% def in Opts->Defines) + { + String s = marshalString(def); + C->getPreprocessorOpts().addMacroDef(s); + } + // Initialize the default platform headers. std::string ResourceDir = GetClangResourceDir("."); C->getHeaderSearchOpts().ResourceDir = ResourceDir; diff --git a/src/Parser/Parser.h b/src/Parser/Parser.h index d307e160..70262a2f 100644 --- a/src/Parser/Parser.h +++ b/src/Parser/Parser.h @@ -37,10 +37,12 @@ public ref struct ParserOptions ParserOptions() { IncludeDirs = gcnew List(); + Defines = gcnew List(); } // Include directories List^ IncludeDirs; + List^ Defines; // C/C++ header file name. System::String^ FileName;