Olly Betts
2015-01-07 00:08:11 UTC
Currently the extension for generated C++ files is ".cxx" for all languages
except for PHP where it's ".cpp" (there is no good reason for this divergence
that I'm aware of - tracking the change back it appears to come from
"The great merge" back in 2002).
You can change this for PHP with:
swig -php -cppext cc
And in fact our own testsuite uses this to change the extension back to cxx!
For Ocaml we provide an option with the same effect, but a different name:
swig -ocaml -suffix cc
For other languages you can't change the extension directly, but you can
specify a filename with extension using -o:
swig -python -o foo_wrap.cc
The current situation seems less than ideal to me, but I thought I should
canvas opinions rather than just changing things.
I think it is useful to be able to specify the extension, as some compilers
and build tools are fussy about it, and there's no good reason why this
shouldn't be supported for all backends. That would just be a matter of
moving the code which handles this option, as it just calls
SWIG_config_cppext(ext).
I think -cppext is a better name than -suffix - (particularly as this is
only used for C++ files), so I propose that -suffix remain supported for
now as an Ocaml-specific option, but prints a warning that it is deprecated
and that -cppext is preferred as of SWIG 3.0.4 (or whatever version).
I don't like the PHP backend having a different default, though changing
that is an incompatible change for anyone generating PHP bindings and not
using -cppext or -o.
Cheers,
Olly
except for PHP where it's ".cpp" (there is no good reason for this divergence
that I'm aware of - tracking the change back it appears to come from
"The great merge" back in 2002).
You can change this for PHP with:
swig -php -cppext cc
And in fact our own testsuite uses this to change the extension back to cxx!
For Ocaml we provide an option with the same effect, but a different name:
swig -ocaml -suffix cc
For other languages you can't change the extension directly, but you can
specify a filename with extension using -o:
swig -python -o foo_wrap.cc
The current situation seems less than ideal to me, but I thought I should
canvas opinions rather than just changing things.
I think it is useful to be able to specify the extension, as some compilers
and build tools are fussy about it, and there's no good reason why this
shouldn't be supported for all backends. That would just be a matter of
moving the code which handles this option, as it just calls
SWIG_config_cppext(ext).
I think -cppext is a better name than -suffix - (particularly as this is
only used for C++ files), so I propose that -suffix remain supported for
now as an Ocaml-specific option, but prints a warning that it is deprecated
and that -cppext is preferred as of SWIG 3.0.4 (or whatever version).
I don't like the PHP backend having a different default, though changing
that is an incompatible change for anyone generating PHP bindings and not
using -cppext or -o.
Cheers,
Olly