lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> What I really meant was that with that macro you could perform the
> cast on the pointer returned from malloc only when compiling as C++,
> and avoid the cast in C, in order to "conform" to C best practices
> [1] that advice against casting that pointer (as opposed as what you
> should do in C++), as Sean said.

Let us see [1]:

* "It is unnecessary" - so are comments, identation, etc.

* "It can hide an error, if you forgot to include <stdlib.h>." - This
could be a valid argument 20 years ago (K&R C). If you do not use
something like -Wstrict-prototypes and -Wmissing-prototypes, something
is very wrong, as every single function call in your program could hide
errors.

* "It adds clutter to the code" - A macro would add even more "clutter".

* "It makes you repeat yourself" - So does a macro.

-- Roberto