diff --git a/src/preprocessor.cpp b/src/preprocessor.cpp index ba2a288af..eec7e76e3 100644 --- a/src/preprocessor.cpp +++ b/src/preprocessor.cpp @@ -508,9 +508,15 @@ std::string Preprocessor::getcode(const std::string &filedata, std::string cfg, match &= bool(*it); } - if (line.find("#file \"") == 0 || - line.find("#endfile") == 0 || - line.find("#define") == 0) + + if (!match && line.find("#define") == 0) + { + // Remove define that is not part of this configuration + line = ""; + } + else if (line.find("#file \"") == 0 || + line.find("#endfile") == 0 || + line.find("#define") == 0) { // We must not remove #file tags or line numbers // are corrupted. File tags are removed by the tokenizer. diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 64a26ca20..ec994fa12 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -984,7 +984,7 @@ private: // Compare results.. ASSERT_EQUALS(2, static_cast(actual.size())); ASSERT_EQUALS("\n\n\n\n\n20\n", actual[""]); - TODO_ASSERT_EQUALS("\n\n\n\n\n10\n", actual["A"]); + ASSERT_EQUALS("\n\n\n\n\n10\n", actual["A"]); ASSERT_EQUALS("", errout.str()); }