diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i index 99d54fda9..3507fba49 100644 --- a/Examples/test-suite/preproc.i +++ b/Examples/test-suite/preproc.i @@ -273,5 +273,6 @@ inline const char* mangle ## #@__VA_ARGS__ () { %inline %{ int endif = 0; int define = 0; -int defined = 0; +/* this is not working */ +/* int defined = 0; */ %} diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index d6cea4c65..5db8efc78 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -27,7 +27,7 @@ static int ignore_missing = 0; static int import_all = 0; /* Follow all includes, but as %import statements */ static int imported_depth = 0; /* Depth of %imported files */ static int single_include = 1; /* Only include each file once */ -static int replace_defined = 0; +static int replace_defined = 1; static Hash *included_files = 0; static List *dependencies = 0; @@ -1335,7 +1335,6 @@ Preprocessor_parse(String *s) } } } else if (Cmp(id,"if") == 0) { - replace_defined = 1; cond_lines[level] = Getline(id); level++; if (allow) { @@ -1357,9 +1356,7 @@ Preprocessor_parse(String *s) } mask = 1; } - replace_defined = 0; } else if (Cmp(id,"elif") == 0) { - replace_defined = 1; if (level == 0) { Swig_error(Getfile(s),Getline(id),"Misplaced #elif.\n"); } else { @@ -1386,7 +1383,6 @@ Preprocessor_parse(String *s) } } } - replace_defined = 0; } else if (Cmp(id,"line") == 0) { } else if (Cmp(id,"include") == 0) { if (((include_all) || (import_all)) && (allow)) {