[<<][erlang][>>][..]
Thu Mar 3 14:24:03 EST 2016

macros and binops

Don't forget parenthesis!

use:
-define(FRAMES_PER_BLOCK,(?BLOCK_SIZE div ?FRAME_SIZE)).

this will lead to surprises:
-define(FRAMES_PER_BLOCK,?BLOCK_SIZE div ?FRAME_SIZE).

I had previously assumed macros do subexpression replacement, but it
looks like they do token replacement!

Actually, from the code it looks like I ran into this before:

-define(PLAYBACK_READFLAGS,  (1 bsl 0)).
-define(PLAYBACK_FILLBAD,    (1 bsl 1)).
-define(PLAYBACK_CHECKBLOCK, (1 bsl 2)).




[Reply][About]
[<<][erlang][>>][..]