diff --git a/CHANGES.current b/CHANGES.current index 3dcc63e2f..39d67e90b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.3.0 (in progress) =========================== +2024-09-25: olly + Add support for C99 _Bool. SWIG now treats _Bool as an alias for + the bool keyword when in C mode. + 2024-09-24: olly #2884 SWIG no longer accepts the invalid definition of a function as the final part of a declaration, e.g. diff --git a/Examples/test-suite/cbooltest.i b/Examples/test-suite/cbooltest.i new file mode 100644 index 000000000..6c3f4f318 --- /dev/null +++ b/Examples/test-suite/cbooltest.i @@ -0,0 +1,23 @@ +%module cbooltest + +%{ +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +/* C99 _Bool should be supported by the compiler. */ +# include +#else +/* C99 _Bool and stdbool.h may not be supported, so define a hacky version so + * we can still test SWIG's support. */ +# define _Bool unsigned char +# define bool _Bool +# define true 1 +# define false 1 +#endif +%} + +%inline %{ +_Bool do_and(_Bool a, _Bool b) { return a && b; } +_Bool do_or(_Bool a, _Bool b) { return a || b; } +%} + +%constant _Bool TRUE_CONSTANT = true; +%constant _Bool FALSE_CONSTANT = false; diff --git a/Examples/test-suite/errors/cpp_c_bool.i b/Examples/test-suite/errors/cpp_c_bool.i new file mode 100644 index 000000000..8e34fb544 --- /dev/null +++ b/Examples/test-suite/errors/cpp_c_bool.i @@ -0,0 +1,5 @@ +%module xxx +struct A { + // C99 _Bool should not be a keyword in C++ so this should not give an error. + bool _Bool; +}; diff --git a/Examples/test-suite/errors/cpp_c_bool.stderr b/Examples/test-suite/errors/cpp_c_bool.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/Examples/test-suite/php/cbooltest_runme.php b/Examples/test-suite/php/cbooltest_runme.php new file mode 100644 index 000000000..cd34252cd --- /dev/null +++ b/Examples/test-suite/php/cbooltest_runme.php @@ -0,0 +1,8 @@ +