Smoking out C extension mistakes

D

Daniel Berger

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
 
P

Paul Brannan

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
 
T

ts

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

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

:)


Guy Decoux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top