Compiler: Add #warning directive.

Basically same as error but as warning.
Imported from SA-MP: 1bd6be93e0

Example:

  #warning don't eat egg.

Result:

  warning.sma(1) : warning 234: user warning: don't eat egg.
This commit is contained in:
Arkshine
2014-08-14 20:58:13 +02:00
parent 92255bcdc3
commit fcdeea683b
3 changed files with 22 additions and 12 deletions

View File

@ -1351,6 +1351,14 @@ static int command(void)
if (!SKIPPING)
error(111,lptr); /* user error */
break;
case tpWARNING:
while (*lptr<=' ' && *lptr!='\0')
lptr++;
if (!SKIPPING) {
str=strtok((char*)lptr, "\n");
error(234, str != NULL ? str : lptr); /* user warning, and remove unnecessary newline */
}
break;
default:
error(31); /* unknown compiler directive */
ret=SKIPPING ? CMD_CONDFALSE : CMD_NONE; /* process as normal line */
@ -1831,7 +1839,7 @@ char *sc_tokens[] = {
"sleep", "state", "static", "stock", "switch", "tagof", "while",
"#assert", "#define", "#else", "#elseif", "#emit", "#endif", "#endinput",
"#endscript", "#error", "#file", "#if", "#include", "#line", "#pragma",
"#tryinclude", "#undef",
"#tryinclude", "#undef", "#warning",
";", ";", "-integer value-", "-rational value-", "-identifier-",
"-label-", "-string-"
};