[Top][All Lists]

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

Re: [Chicken-users] checking whether a C macro is defined

From: Jim Ursetto
Subject: Re: [Chicken-users] checking whether a C macro is defined
Date: Thu, 16 Aug 2012 21:05:32 -0500

That should be foreign-declare for the whole thing, not foreign-code.
Or use #> ... <# which is shorthand for foreign-declare.

#include <foo.h>
#ifndef FOO
#define FOO -1

Another option is the feature-test egg, which is useful for complex cases,
and doesn't require that you redefine anything.

But for cases where it is safe to #define an undefined macro (in other words,
when you can guarantee there is an impossible, harmless or safe default value),
the above is easier.

On Aug 16, 2012, at 6:37 PM, Antony Lee wrote:

Hi all,
I am looking for a way to check if a symbol is #defined as a C macro or not... something like

(declare (foreign-declare "#include <foo.h>"))
(foreign-code #<<EOF
#ifndef FOO
#define FOO -1
(define-foreign-variable FOO int)

which doesn't work (because I cannot put C macros in foreign-code?).

My second try was to use the bind egg:
(bind* #<<EOF
#ifndef FOO
#define FOO -1

but now FOO is always redefined (i.e. #ifndef FOO always evaluates to true).

Any suggestions?  (I guess I could always put all that in an actual header file full of #ifndef's and #include *that* one but I am looking for something more... elegant if possible.)
Chicken-users mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]