I'm trying to write a PureBasic macro that declares a `Protected.s` variable named after the current procedure using `#PB_Compiler_Procedure`. Here's what I attempted:
Code: Select all
Macro CreateProtectedStringVarWithProcName()
Protected.s #PB_Compiler_Procedure
EndMacro
Procedure.s MyProcedure()
CreateProtectedStringVarWithProcName() ; expands to 'Protected.s #PB_Compiler_Procedure' → syntax error
EndProcedure
Interestingly, this works fine when passing `#PB_Compiler_Procedure` as a parameter:
Code: Select all
Procedure.s MyProcedure(sString$)
ProcedureReturn sString$
EndProcedure
Procedure CallMyDebug()
Debug MyProcedure(#PB_Compiler_Procedure) ; expands correctly
EndProcedure
Or is there a workaround to dynamically name a variable based on the procedure name?
Any insights or alternative approaches would be appreciated!

