From 6b3c30aa9e4fcea7b69c0ef5253c7bca568a8669 Mon Sep 17 00:00:00 2001 From: Zeex Date: Mon, 6 Apr 2015 18:06:58 +0600 Subject: [PATCH] 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`. --- source/compiler/sc1.c | 1 + source/compiler/sc2.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 34fe41f..fb91b0c 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -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)) diff --git a/source/compiler/sc2.c b/source/compiler/sc2.c index e739669..3bcbe8e 100644 --- a/source/compiler/sc2.c +++ b/source/compiler/sc2.c @@ -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 */