diff --git a/CHANGES.current b/CHANGES.current index 05f2722a0..6d72022db 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,18 @@ Version 1.3.21 (in progress) ================================== +01/10/2004: cheetah (William Fulton) + The output format for both warnings and errors can be selected for + integration with your favourite IDE/editor. Editors and IDEs can usually + parse error messages and if in the appropriate format will easily take you + directly to the source of the error. The standard format is used by + default except on Windows where the Microsoft format is used by default. + These can be overridden using command line options, for example: + + $ swig -python -Fstandard example.i + example.i:4: Syntax error in input. + $ swig -python -Fmicrosoft example.i + example.i(4): Syntax error in input. + 01/09/2004: beazley Fixed [ 871909 ] simple namespace problem. This was a problem using anonymous structures in a namespace. diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 6f6d2df72..88752813f 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -107,16 +107,18 @@ following options and a filename like this: -tcl Generate Tcl wrappers -xml Generate XML wrappers -c++ Enable C++ parsing +-Dsymbol Define a preprocessor symbol +-Fstandard Display error/warning messages in commonly used format +-Fmicrosoft Display error/warning messages in Microsoft format +-help Display all options -Idir Add a directory to the file include path -lfile Include a SWIG library file. +-module name Set the name of the SWIG module -noruntime Generate raw wrapper code (omit supporting code) -o outfile Name of output file -outdir dir Set language specific files output directory --module name Set the name of the SWIG module --Dsymbol Define a preprocessor symbol --version Show SWIG version number -swiglib Show location of SWIG library --help Display all options +-version Show SWIG version number @@ -2655,4 +2657,4 @@ The bottom line: don't do this.
SWIG 1.3 - Last Modified : August 7, 2003
- \ No newline at end of file + diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index add021f10..6fa65df73 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -13,17 +13,18 @@
  • Enabling additional warnings
  • Issuing a warning message
  • Commentary -
  • Warning number reference +
  • Message output format +
  • Warning number reference -
  • History +
  • History @@ -221,10 +222,27 @@ no obvious recovery. There is no mechanism for suppressing error messages or handling errors as warnings---you must make changes to the input file to fix the problem. -

    12.6 Warning number reference

    +

    12.6 Message output format

    -

    12.6.1 Deprecated features (100-199)

    +The output format for both warnings and errors can be selected for +integration with your favourite IDE/editor. Editors and IDEs can usually parse +error messages and if in the appropriate format will easily take you +directly to the source of the error. The standard format is used by +default except on Windows where the Microsoft format is used by default. +These can be overridden using command line options, for example: + +
    +$ swig -python -Fstandard example.i
    +example.i:4: Syntax error in input.
    +$ swig -python -Fmicrosoft example.i
    +example.i(4): Syntax error in input.
    +
    + +

    12.7 Warning number reference

    + + +

    12.7.1 Deprecated features (100-199)

    -

    12.6.2 Preprocessor (200-299)

    +

    12.7.2 Preprocessor (200-299)

    -

    12.6.3 C/C++ Parser (300-399)

    +

    12.7.3 C/C++ Parser (300-399)

    -

    12.6.4 Types and typemaps (400-499)

    +

    12.7.4 Types and typemaps (400-499)

    -

    12.6.5 Code generation (500-599)

    +

    12.7.5 Code generation (500-599)

    -

    12.6.6 Language module specific (800-899)

    +

    12.7.6 Language module specific (800-899)

    -

    12.6.7 User defined (900-999)

    +

    12.7.7 User defined (900-999)

    These numbers can be used by your own application. -

    12.7 History

    +

    12.8 History

    The ability to control warning messages was first added to SWIG-1.3.12. diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index e7fe8130d..8bb08c42d 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -48,7 +48,7 @@ extern "C" { extern String *ModuleName; } -static char *usage = (char*)"\ +static const char *usage1 = (const char*)"\ \nGeneral Options\n\ -c++ - Enable C++ processing\n\ -co - Check a file out of the SWIG library\n\ @@ -57,6 +57,8 @@ static char *usage = (char*)"\ -E - Preprocess only, does not generate wrapper code\n\ -fcompact - Compile in compact mode\n\ -fvirtual - Compile in virtual elimination mode\n\ + -Fstandard - Display error/warning messages in commonly used format\n\ + -Fmicrosoft - Display error/warning messages in Microsoft format\n\ -help - This output\n\ -I - Look for SWIG files in \n\ -ignoremissing - Ignore missing include files\n\ @@ -65,6 +67,9 @@ static char *usage = (char*)"\ -l - Include SWIG library file \n\ -M - List all dependencies \n\ -MM - List dependencies, but omit files in SWIG library\n\ +"; +// usage string split in two otherwise string is too big for some compilers +static const char *usage2 = (const char*)"\ -makedefault - Create default constructors/destructors (the default)\n\ -module - Set module name to \n\ -nocontract - Turn off contract checking \n\ @@ -484,8 +489,15 @@ int SWIG_main(int argc, char *argv[], Language *l) { } else if (strcmp(argv[i],"-dump_memory") == 0) { memory_debug =1; Swig_mark_arg(i); + } else if (strcmp(argv[i],"-Fstandard") == 0) { + Swig_error_msg_format(EMF_STANDARD); + Swig_mark_arg(i); + } else if (strcmp(argv[i],"-Fmicrosoft") == 0) { + Swig_error_msg_format(EMF_MICROSOFT); + Swig_mark_arg(i); } else if (strcmp(argv[i],"-help") == 0) { - fputs(usage,stderr); + fputs(usage1,stderr); + fputs(usage2,stderr); Swig_mark_arg(i); help = 1; } diff --git a/Source/Swig/error.c b/Source/Swig/error.c index 32028822f..ebf42d9b2 100644 --- a/Source/Swig/error.c +++ b/Source/Swig/error.c @@ -34,10 +34,16 @@ char cvsroot_error_c[] = "$Header$"; * is reenabled. * ----------------------------------------------------------------------------- */ +#if defined(_WIN32) +# define DEFAULT_ERROR_MSG_FORMAT EMF_MICROSOFT +#else +# define DEFAULT_ERROR_MSG_FORMAT EMF_STANDARD +#endif +static ErrorMessageFormat msg_format = DEFAULT_ERROR_MSG_FORMAT; static int silence = 0; /* Silent operation */ static String *filter = 0; /* Warning filter */ static int warnall = 0; -static int nwarning = 0; +static int nwarning = 0; /* ----------------------------------------------------------------------------- * Swig_warning() @@ -84,9 +90,25 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt } if (warnall || wrn) { if (wnum) { - Printf(stderr,"%s:%d: Warning(%d): ", filename, line, wnum); + switch (msg_format) { + case EMF_MICROSOFT: + Printf(stderr,"%s(%d): Warning(%d): ", filename, line, wnum); + break; + case EMF_STANDARD: + default: + Printf(stderr,"%s:%d: Warning(%d): ", filename, line, wnum); + break; + } } else { - Printf(stderr,"%s:%d: Warning: ", filename, line, wnum); + switch (msg_format) { + case EMF_MICROSOFT: + Printf(stderr,"%s(%d): Warning: ", filename, line); + break; + case EMF_STANDARD: + default: + Printf(stderr,"%s:%d: Warning: ", filename, line); + break; + } } Printf(stderr,"%s",msg); nwarning++; @@ -111,7 +133,15 @@ Swig_error(const String_or_char *filename, int line, const char *fmt, ...) { va_start(ap,fmt); if (line > 0) { - Printf(stderr,"%s:%d: ", filename, line); + switch (msg_format) { + case EMF_MICROSOFT: + Printf(stderr,"%s(%d): ", filename, line); + break; + case EMF_STANDARD: + default: + Printf(stderr,"%s:%d: ", filename, line); + break; + } } else { Printf(stderr,"%s:EOF: ", filename); } @@ -197,3 +227,13 @@ Swig_warn_count(void) { return nwarning; } +/* ----------------------------------------------------------------------------- + * Swig_error_msg_format() + * + * Set the type of error/warning message display + * ----------------------------------------------------------------------------- */ + +void +Swig_error_msg_format(ErrorMessageFormat format) { + msg_format = format; +} diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index b11a4a1c5..8525bf299 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -415,6 +415,8 @@ extern void Swig_warn(const char *filename, int line, const char *msg); #define WARNING(msg) Swig_warn(__FILE__,__LINE__,msg) +typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat; + extern void Swig_warning(int num, const String_or_char *filename, int line, const char *fmt, ...); extern void Swig_error(const String_or_char *filename, int line, const char *fmt, ...); extern int Swig_error_count(void); @@ -422,6 +424,7 @@ extern void Swig_error_silent(int s); extern void Swig_warnfilter(const String_or_char *wlist, int val); extern void Swig_warnall(void); extern int Swig_warn_count(void); +extern void Swig_error_msg_format(ErrorMessageFormat format); /* --- C Wrappers --- */ extern String *Swig_cparm_name(Parm *p, int i);