swig/Examples/test-suite/preproc_predefined.i
Olly Betts 4ac3c87a29 Sort out predefined SWIG-specific macros
Ensure that SWIG_VERSION is defined both at SWIG-time and in the
generated C/C++ wrapper code (it was only defined in the wrapper
for some target languages previously).

SWIGGO and SWIGJAVASCRIPT are now defined in the generated wrappers
to match behaviour for all other target languages.

Stop defining SWIGVERSION in the wrapper.  This only happened as a
side-effect of how SWIG_VERSION was defined but was never documented and
is redundant.

The new testcase also checks that SWIG is defined at SWIG-time but not
in the generated wrapper, and that exactly one of a list of
target-language specific macros is defined.

Fixes #1050
2022-10-05 12:40:15 +13:00

40 lines
1 KiB
OpenEdge ABL

%module preproc_predefined
/* Test that SWIG_VERSION is defined at SWIG-time and in the wrapper. */
#ifndef SWIG_VERSION
# error SWIG_VERSION not defined at SWIG-time
#endif
%{
#ifndef SWIG_VERSION
# error SWIG_VERSION not defined in the generated wrapper
#endif
%}
/* Test that SWIGVERSION is NOT defined at SWIG-time or in the wrapper.
* It used to be defined in the wrapper as a side-effect of how SWIG_VERSION
* was defined in the wrapper but was never documented and is redundant.
*/
#ifdef SWIGVERSION
# error SWIGVERSION should not be defined at SWIG-time
#endif
%{
#ifdef SWIGVERSION
# error SWIGVERSION should not be defined in the generated wrapper
#endif
%}
/* Test that SWIG is defined at SWIG-time but not in the wrapper. */
#ifndef SWIG
# error SWIG not defined at SWIG-time
#endif
%{
#ifdef SWIG
# error SWIG should not be defined in the generated wrapper
#endif
%}
/* Test that SWIGxxx is defined at SWIG-time and in the wrapper. */
%include "preproc_predefined.h"
%{
#include "preproc_predefined.h"
%}