diff --git a/source/dpp/translation/macro_.d b/source/dpp/translation/macro_.d index 4272a693..6ad274a2 100644 --- a/source/dpp/translation/macro_.d +++ b/source/dpp/translation/macro_.d @@ -74,15 +74,16 @@ string[] translateMacro(in from!"clang".Cursor cursor, ]; } } + return [ `#ifdef ` ~ spelling, `# undef ` ~ spelling, `#endif`, - `static if(!is(typeof(` ~ spelling ~ `))) {`, - ] ~ ret ~ [ - `}`, - `#define ` ~ spelling ~ ` ` ~ translation.dcode, - ]; + ] ~ + ret ~ + [ + `#define ` ~ spelling ~ ` ` ~ translation.dcode, + ]; } // Define a template function with the same name as the macro diff --git a/tests/it/issues.d b/tests/it/issues.d index ffded030..0d393809 100644 --- a/tests/it/issues.d +++ b/tests/it/issues.d @@ -937,6 +937,12 @@ version(linux) // linux specific header in the test } } +// the original fix for this issue had to do with ordering, but it +// also ended up guarding a `static if` that checked if a macro +// already existed before trying to define it again. Unfortunately, +// too many static ifs caused the compiler to have ordering problems, +// but removing that caused this test to fail. The "fix" is to ask for +// scoped enums so that it doesn't try to define `BAR` twice. @Tags("issue") @("79") unittest { @@ -960,7 +966,8 @@ unittest { // The bug had to do with ordering. enum TheEnum { BAR = 42 }; `); - runPreprocessOnly("app.dpp"); + + runPreprocessOnly("app.dpp", "--scoped-enums"); shouldCompile("app.d"); } }