Smoking out C extension mistakes

Hi all,

Every once in a while I’ll hit a segfault that turns out to be caused by
accidentally passing a C datatype to a macro like NIL_P (which,
naturally, I
can’t duplicate with a simple example, but recently occurred in
win32-eventlog).

Anyhoo, say I have something like this:

char* foo = “hello”;
if(NIL_P(foo)) /* whoops */

I noticed that even compiling with gcc using -Wall -W I still don’t see
a
warning. Is this because it’s a macro? Is there a gcc option I can use
to
help me smoke these sorts of mistakes out?

Thanks,

Dan

On Wed, Jan 11, 2006 at 01:18:19AM +0900, Daniel B. wrote:

char* foo = “hello”;
if(NIL_P(foo)) /* whoops */

I noticed that even compiling with gcc using -Wall -W I still don’t see a
warning. Is this because it’s a macro? Is there a gcc option I can use to
help me smoke these sorts of mistakes out?

You could use:

if(foo == Qnil)

instead of using the NIL_P macro.

Paul

“P” == Paul B. [email protected] writes:

P> You could use:
P> if(foo == Qnil)
P> instead of using the NIL_P macro.

#define NIL_P(v) ((VALUE)(v) == Qnil)

:slight_smile:

Guy Decoux