lua-users home
lua-l archive

Re: [patch][c++] fix "invalid conversion from ‘void*’ to ‘char*’"

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


On 28/06/2016 19:00, Roberto Ierusalimschy wrote:
Wouldn't it be useful to use some macro magic to remove the cast
when the code is built as plain C, so that the code the compiler
sees is conforming both as C and as C++?
Currently, the code the compiler sees is already conforming both to C
and C++. Why that macro would be useful?
Sorry, I used the wrong words. I didn't really mean "conforming" as "conforming C implementation". 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.
-- Roberto
[1] http://stackoverflow.com/a/605858/2633423

AltStyle によって変換されたページ (->オリジナル) /