#PB_Macro for Defined()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

#PB_Macro for Defined()

Post by infratec »

Hi,

I just came accross a problem:
I need to know if a Macro is already defined (many include files :( )

I tried to use

Code: Select all

CompilerIf Not Defined()
But ...

#PB_Macro does not exist.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: #PB_Macro for Defined()

Post by skywalk »

Yeah, I check a constant defined within my common macros.
Undefine macro
Define macro could be a workaround?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: #PB_Macro for Defined()

Post by Little John »

Hi,

this was discussed before:
viewtopic.php?f=13&t=46310

Anyway, it's good to have a feature request for it now in the appropriate forum section.
acreis
Enthusiast
Enthusiast
Posts: 182
Joined: Fri Jun 01, 2012 12:20 am

Re: #PB_Macro for Defined()

Post by acreis »

Code: Select all

Macro CompilerIfNotDefinedMacro(_Macro_Name_)

CompilerIf Defined(_Macro_Name_#_Defined_, #PB_Constant) = 0
  #_Macro_Name_#_Defined_ = 1
  
  EndMacro
  
  
  
CompilerIfNotDefinedMacro(MyMacro)
  
  Macro MyMacro()
    
    Debug 14
    
  EndMacro   
  
CompilerEndIf


CompilerIfNotDefinedMacro(MyMacro)

Macro MyMacro()
    
    Debug 25
    
  EndMacro   
  
CompilerEndIf

MyMacro()
Post Reply