Labels can be defined then undefined in gas or gcc (32 and 64) bits.
However variables (in my macro) can only be defined then undefined in gas (32 and 64)
Gcc throws an error if undefining variables.
So, I was wondering if defining and undefining labels many times is OK, since none of the fb compilers complain about it.
The whole point of the exercise is to make a macro as self sufficient as possible, allowing goto (and gosub) and labels inside them.
I can scope off variables of course, or do something like :.
Code: Select all
#cmdline "-gen gas64"
#macro MyMacro(commence,limit,result)
#define finish finishlabel
#define start startlabel
#if __FB_BACKEND__ = "gas64"
dim as long x
dim as string acc
#else
#ifndef x
dim as long x
#endif
#ifndef acc
dim as string acc
#endif
#endif
x=commence
acc=""
start:
do
acc+=str(x)+" "
x+=1
if abs(x) <=limit then goto start else goto finish
loop
finish:
result=acc
#undef startlabel
#undef finishlabel
#if __FB_BACKEND__ = "gas64"
#undef x
#undef acc
#endif
#endmacro
'==================================
dim as string z,g
for n as long=1 to 100000
MyMacro(n,0,g)
z+= g
next n
print z
print
MyMacro(8,30,g)
print g
MyMacro(56,60,g)
print g
print "backend "; __FB_BACKEND__
Sleep