Add new built-in constant __compat

The __compat constant is set to 0 when compatibility mode is disabled
and 1 (or some non-zero value) if enabled, either by using -Z or with
`#pragma compat`.
This commit is contained in:
Zeex 2015-04-06 18:06:58 +06:00
parent 898e02b771
commit 6b3c30aa9e
2 changed files with 5 additions and 0 deletions

View File

@ -1495,6 +1495,7 @@ static void setconstants(void)
add_constant("__Pawn",VERSION_INT,sGLOBAL,0);
add_constant("__line",0,sGLOBAL,0);
add_constant("__compat",pc_compat,sGLOBAL,0);
debug=0;
if ((sc_debug & (sCHKBOUNDS | sSYMBOLIC))==(sCHKBOUNDS | sSYMBOLIC))

View File

@ -1237,8 +1237,12 @@ static int command(void)
}
} else if (strcmp(str,"compat")==0) {
cell val;
symbol *sym;
preproc_expr(&val,NULL);
pc_compat=(int)val; /* switch compatibility mode on/off */
sym=findconst("__compat",NULL);
assert(sym!=NULL);
sym->addr=pc_compat;
} else {
error(207); /* unknown #pragma */
} /* if */