[vlc-devel] Macros & IDE
pdherbemont at free.fr
Sun Nov 25 18:54:03 CET 2007
On Nov 25, 2007, at 10:40 AM, Jean-Paul Saman wrote:
> Jean-Baptiste Kempf wrote:
>> On Sun, Nov 25, 2007, Guy Paddock wrote :
>>> Quick question: why does the VLC source use macros so much? I
>>> mean, I
>>> understand their use for ensuring unique function names in case
>>> modules are compiled-in or built separately, but IMO they seem to be
>>> overused. Personally, I like to avoid macros like the plague because
>>> they're not context-safe, but that's just me.
To me;,there are clearly some macro abuses in VLC. Feel free to clean
However some macro uses are legitimate and needed, especially to
implement VLC's object abstraction.
>> I am interested to know also why we use huge #defines when we could
>> enum. Is this better code-size wise ? Faster ?
> Defines are resolved at compile time, while enums are runtime used.
I think that defines have some nifty advantages, such as:
- finer grain control for bitmask
- possibility to #ifdef them.
This is needed in some very particular cases.
But enum provide a way better abstraction to define constants, with
much more advantages over #defines in most cases: The compiler can,
optimize enum uses and most importantly type check and error detect.
This error checking is by itself sufficient to largely prefer enum
We do have some non-optimal uses of #define.
So, feel free to patch that (IMO).
More information about the vlc-devel