diff --git a/compiler/options.pas b/compiler/options.pas index b131897aaa..80465c80bd 100644 --- a/compiler/options.pas +++ b/compiler/options.pas @@ -603,8 +603,13 @@ begin 'd' : if more <> '' then - def_system_macro(more); - + begin + l:=Pos(':=',more); + if l>0 then + set_system_compvar(Copy(more,1,l-1),Copy(more,l+2,255)) + else + def_system_macro(more); + end; 'D' : begin include(initglobalswitches,cs_link_deffile); diff --git a/compiler/symtable.pas b/compiler/symtable.pas index a22ac9e458..658f851acf 100644 --- a/compiler/symtable.pas +++ b/compiler/symtable.pas @@ -227,6 +227,7 @@ interface {Name can be given in any case (it will be converted to upper case).} procedure def_system_macro(const name : string); procedure set_system_macro(const name, value : string); + procedure set_system_compvar(const name, value : string); procedure undef_system_macro(const name : string); {*** symtable stack ***} @@ -2321,6 +2322,37 @@ implementation mac.defined:=true; end; + procedure set_system_compvar(const name, value : string); + var + mac : tmacro; + s: string; + begin + if name = '' then + internalerror(2004121201); + s:= upper(name); + mac:=tmacro(search_macro(s)); + if not assigned(mac) then + begin + mac:=tmacro.create(s); + mac.is_compiler_var:=true; + if macrosymtablestack.symtabletype=localmacrosymtable then + macrosymtablestack.insert(mac) + else + macrosymtablestack.next.insert(mac) + end + else + begin + mac.is_compiler_var:=true; + if assigned(mac.buftext) then + freemem(mac.buftext,mac.buflen); + end; + Message2(parser_c_macro_set_to,mac.name,value); + mac.buflen:=length(value); + getmem(mac.buftext,mac.buflen); + move(value[1],mac.buftext^,mac.buflen); + mac.defined:=true; + end; + procedure undef_system_macro(const name : string); var mac : tmacro;