set macro value depending on compilation parameters

Roberto Ostinelli roberto@REDACTED
Sun Oct 25 01:25:40 CEST 2009

dear all,

i need to define a macro to expand differently depending on a macro
value passed at compilation time.

for instance, consider the following macro declared inside a module 'test':

-define(FCTN, true).

now, what i would like is that if i compile the module 'test' like this:

1>c(test, {d, foo, bar}).
{ok, test}

then inside module 'foo' the macro ?FCTN expands to true [as per the
example above], while if i compile like this:

1>c(test, {d, foo, baz}).
{ok, test}

then inside module 'foo' the macro ?FCTN expands to false.

the way i'm currently using to achieve this is:

-define(FCTN, case ?foo of
	bar ->
	baz ->

however, i do not want to have FCTN perform a case condition every
time it is called, since it will ALWAYS return one of the two options
once it is compiled. is erlc already optimizing this, ignoring the
case condition? or is there another [and better] way to achieve this

thank you for any suggestions you may have.



More information about the erlang-questions mailing list