-DFOO on the SWIG command line now sets FOO to 1
This is consistent with C/C++ compiler preprocessors. Previously SWIG set FOO to an empty value. Fixes #2193
This commit is contained in:
parent
9d7c962ee8
commit
b06ab566cb
4 changed files with 18 additions and 1 deletions
|
|
@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
||||||
Version 4.1.0 (in progress)
|
Version 4.1.0 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2022-02-06: olly
|
||||||
|
#2193 -DFOO on the SWIG command line now sets FOO to 1 for
|
||||||
|
consistency with C/C++ compiler preprocessors. Previously
|
||||||
|
SWIG set FOO to an empty value.
|
||||||
|
|
||||||
2022-02-06: sethrj
|
2022-02-06: sethrj
|
||||||
#2194 Classes that are non-assignable due to const data or const
|
#2194 Classes that are non-assignable due to const data or const
|
||||||
reference members are now automatically detected.
|
reference members are now automatically detected.
|
||||||
|
|
|
||||||
7
Examples/test-suite/command_line_define.i
Normal file
7
Examples/test-suite/command_line_define.i
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
%module command_line_define
|
||||||
|
|
||||||
|
// Test handling of -D without a value specified.
|
||||||
|
|
||||||
|
#if FOO-0 != 1
|
||||||
|
# error "-DFOO didn't set FOO to 1"
|
||||||
|
#endif
|
||||||
|
|
@ -692,6 +692,7 @@ C_TEST_CASES += \
|
||||||
c_delete \
|
c_delete \
|
||||||
c_delete_function \
|
c_delete_function \
|
||||||
char_constant \
|
char_constant \
|
||||||
|
command_line_define \
|
||||||
const_const \
|
const_const \
|
||||||
constant_expr_c \
|
constant_expr_c \
|
||||||
default_args_c \
|
default_args_c \
|
||||||
|
|
@ -761,6 +762,7 @@ MULTI_CPP_TEST_CASES += \
|
||||||
# Custom tests - tests with additional commandline options
|
# Custom tests - tests with additional commandline options
|
||||||
wallkw.cpptest: SWIGOPT += -Wallkw
|
wallkw.cpptest: SWIGOPT += -Wallkw
|
||||||
preproc_include.ctest: SWIGOPT += -includeall
|
preproc_include.ctest: SWIGOPT += -includeall
|
||||||
|
command_line_define.ctest: SWIGOPT += -DFOO
|
||||||
|
|
||||||
# Allow modules to define temporarily failing tests.
|
# Allow modules to define temporarily failing tests.
|
||||||
C_TEST_CASES := $(filter-out $(FAILING_C_TESTS),$(C_TEST_CASES))
|
C_TEST_CASES := $(filter-out $(FAILING_C_TESTS),$(C_TEST_CASES))
|
||||||
|
|
|
||||||
|
|
@ -477,7 +477,10 @@ static void getoptions(int argc, char *argv[]) {
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if (strncmp(argv[i], "-D", 2) == 0) {
|
} else if (strncmp(argv[i], "-D", 2) == 0) {
|
||||||
String *d = NewString(argv[i] + 2);
|
String *d = NewString(argv[i] + 2);
|
||||||
Replace(d, "=", " ", DOH_REPLACE_FIRST);
|
if (Replace(d, "=", " ", DOH_REPLACE_FIRST) == 0) {
|
||||||
|
// Match C preprocessor behaviour whereby -DFOO sets FOO=1.
|
||||||
|
Append(d, " 1");
|
||||||
|
}
|
||||||
Preprocessor_define((DOH *) d, 0);
|
Preprocessor_define((DOH *) d, 0);
|
||||||
Delete(d);
|
Delete(d);
|
||||||
// Create a symbol
|
// Create a symbol
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue