diff options
Diffstat (limited to 'Source/Modules/main.cxx')
-rw-r--r-- | Source/Modules/main.cxx | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 063275e3b..e94e36cac 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -890,7 +890,9 @@ int SWIG_main(int argc, char *argv[], Language *l) { // Initialize the preprocessor Preprocessor_init(); - lang = l; + // Set lang to a dummy value if no target language was specified so we + // can process options enough to handle -version, etc. + lang = l ? l : new Language; // Set up some default symbols (available in both SWIG interface files // and C files) @@ -923,9 +925,9 @@ int SWIG_main(int argc, char *argv[], Language *l) { Wrapper_director_protected_mode_set(1); // Inform the parser if the nested classes should be ignored unless explicitly told otherwise via feature:flatnested - ignore_nested_classes = l->nestedClassesSupport() == Language::NCS_Unknown ? 1 : 0; + ignore_nested_classes = lang->nestedClassesSupport() == Language::NCS_Unknown ? 1 : 0; - kwargs_supported = l->kwargsSupport() ? 1 : 0; + kwargs_supported = lang->kwargsSupport() ? 1 : 0; // Create Library search directories @@ -960,6 +962,11 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (CPlusPlus) Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0); + if (!l) { + Printf(stderr, "No target language specified\n"); + return 1; + } + // Parse language dependent options lang->main(argc, argv); |