Compile errors with one project only after adding a second project

190 views Asked by At

I have a solution in VS2012 that compiles fine. I wanted to write some unit tests for it and found WinUnit.

For ease, I pulled the WinUnit test project into my solution.

I stripped out their sample file, and began to reference my copy of Google's diff_match_patch that I wanted to test.

As soon as I add the .h file to my project and compile, I get 3 errors in the diff_match_patch file. This file compiled just fine before I added the new project.

Error 3 error C2059: syntax error : '(' ...\diff_match_patch.h 103 1 TestSampleLib

Error 4 error C2143: syntax error : missing ';' before '}' ...\diff_match_patch.h 104 1 TestSampleLib

Error 5 error C2238: unexpected token(s) preceding ';' ...\diff_match_patch.h 104 1 TestSampleLib

All the errors center around this code:

enum Operation {
   DELETE, INSERT, EQUAL
};

I thought it might be some reference that I'm missing, but I've added everything I can think of and its still failing the compile.

These are the only errors i'm getting, so I cant figure out the root cause.

What could make this otherwise compilable file fail?

1

There are 1 answers

1
Chen On BEST ANSWER

It seems macro name pollution. You can try to #undef all the names just before the definition of the enum and see what happens.