Bool() with constants => constant
Posted: Sat Mar 02, 2013 12:11 am
Can the function "Bool" with constants be evaluated at compile time?
Work with PB 5.00:
... but this don't with PB 5.10:
lg Kevin
Work with PB 5.00:
Code: Select all
Macro enum2pow(_const_)
_const_ = ((#PB_Compiler_EnumerationValue=1 And 1) + (#PB_Compiler_EnumerationValue>1 And 1) * ((#PB_Compiler_EnumerationValue-1)<<1))
EndMacro
Enumeration 1
enum2pow(#A1) ;1
enum2pow(#A2) ;2
enum2pow(#A3) ;4
enum2pow(#A4) ;8
EndEnumeration
Code: Select all
Macro enum2pow(_const_)
_const_ = (Bool(#PB_Compiler_EnumerationValue=1) + Bool(#PB_Compiler_EnumerationValue>1) * ((#PB_Compiler_EnumerationValue-1)<<1))
EndMacro