add option/pragma erroraswarn, which force (or not) to treat the cpp #error directive as a #warning instead
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7926 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
922d58ac19
commit
2acc32946b
3 changed files with 28 additions and 2 deletions
|
|
@ -67,6 +67,7 @@ static const char *usage1 = (const char*)"\
|
|||
-ignoremissing - Ignore missing include files\n\
|
||||
-importall - Follow all #include statements as imports\n\
|
||||
-includeall - Follow all #include statements\n\
|
||||
-erroraswarn <v>- Treat (or not) the CPP #error statement as #warning instead\n\
|
||||
-l<ifile> - Include SWIG library file <ifile>\n\
|
||||
-M - List all dependencies \n\
|
||||
-MD - Is equivalent to `-M -MF <file>', except `-E' is not implied\n\
|
||||
|
|
@ -517,6 +518,18 @@ void SWIG_getoptions(int argc, char *argv[])
|
|||
} else if (strcmp(argv[i],"-ignoremissing") == 0) {
|
||||
Preprocessor_ignore_missing(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-erroraswarn") == 0) {
|
||||
String *erroraswarn = 0;
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i+1]) {
|
||||
erroraswarn = NewString(argv[i+1]);
|
||||
Swig_mark_arg(i+1);
|
||||
}
|
||||
if (!erroraswarn) {
|
||||
Swig_arg_error();
|
||||
} else {
|
||||
Preprocessor_error_as_warning(atoi(Char(erroraswarn)));
|
||||
}
|
||||
} else if (strcmp(argv[i],"-tm_debug") == 0) {
|
||||
tm_debug = 1;
|
||||
Swig_mark_arg(i);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ static int single_include = 1; /* Only include each file once */
|
|||
static Hash *included_files = 0;
|
||||
static List *dependencies = 0;
|
||||
static SwigScanner *id_scan = 0;
|
||||
static int error_as_warning = 0; /* Understand the cpp #error directive as a #warning */
|
||||
|
||||
/* Test a character to see if it starts an identifier */
|
||||
#define isidentifier(c) ((isalpha(c)) || (c == '_') || (c == '$'))
|
||||
|
|
@ -247,6 +248,10 @@ void Preprocessor_ignore_missing(int a) {
|
|||
ignore_missing = a;
|
||||
}
|
||||
|
||||
void Preprocessor_error_as_warning(int a) {
|
||||
error_as_warning = a;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Preprocessor_define()
|
||||
|
|
@ -1520,7 +1525,11 @@ Preprocessor_parse(String *s)
|
|||
}
|
||||
} else if (StringEqual(id,k_error)) {
|
||||
if (allow) {
|
||||
Swig_error(Getfile(s),Getline(id),"%s\n",value);
|
||||
if (error_as_warning) {
|
||||
Swig_warning(WARN_PP_CPP_WARNING,Getfile(s),Getline(id),"%s\n", value);
|
||||
} else {
|
||||
Swig_error(Getfile(s),Getline(id),"%s\n",value);
|
||||
}
|
||||
}
|
||||
} else if (StringEqual(id,k_line)) {
|
||||
} else if (StringEqual(id,k_include)) {
|
||||
|
|
@ -1568,9 +1577,12 @@ Preprocessor_parse(String *s)
|
|||
char *c = Char(value)+5;
|
||||
while (*c && (isspace((int)*c))) c++;
|
||||
if (*c) {
|
||||
if (Strncmp(c,"nowarn=",7) == 0) {
|
||||
if (strncmp(c,"nowarn=",7) == 0) {
|
||||
Swig_warnfilter(c+7,1);
|
||||
}
|
||||
else if (strncmp(c,"erroraswarn=",7) == 0) {
|
||||
error_as_warning = atoi(c+12);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (StringEqual(id,k_level)) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ extern String *Preprocessor_parse(String *s);
|
|||
extern void Preprocessor_include_all(int);
|
||||
extern void Preprocessor_import_all(int);
|
||||
extern void Preprocessor_ignore_missing(int);
|
||||
extern void Preprocessor_error_as_warning(int);
|
||||
extern List *Preprocessor_depend(void);
|
||||
extern void Preprocessor_expr_init(void);
|
||||
extern void Preprocessor_expr_delete(void);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue