autoconf
[Top][All Lists]
Advanced

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

how to AC_DEFINE a C macro


From: Stony Yakovac
Subject: how to AC_DEFINE a C macro
Date: Tue, 27 Jul 2004 10:06:56 -0700

I have a case where I am trying to write an autoconf m4 function to
allow me to use several different APIs the same.  In at least one case,
that requires me to define a macro, not just a simple 
#define FOO 1

In trying to do that, I found that AC_DEFINE doesn't like parens no
matter how many "[]"'s you put them in.  That lead me to finding the
definition of AC_DEFINE and AC_DEFINE_UNQUOTED (mysteriously
identical?), which are listed below.

So the questions are:
        1) how would I make an m4 function similar to this 
that would handle macros?  e.g.
#define theirFunc(a) myFunc(a,0)

        2) how is it that AC_DEFINE_UNQUOTED does what its name says?

        3) Can someone help me understand the magic lines here?
I don't understand the "address@hidden:@define]" string, but I assume that it
magically gets transformed into "#define".  I also do not understand
the trailing "1" on the m4_if.  

---/usr/share/autoconf/autoconf/general.m4---
m4_define([AC_DEFINE],
[AC_DEFINE_TRACE([$1])dnl
m4_ifval([$3], [AH_TEMPLATE([$1], [$3])])dnl
cat >>confdefs.h <<\_ACEOF
address@hidden:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
_ACEOF
])
                                                                
# AC_DEFINE_UNQUOTED(VARIABLE, [VALUE], [DESCRIPTION])
# ----------------------------------------------------
# Similar, but perform shell substitutions $ ` \ once on VALUE.
m4_define([AC_DEFINE_UNQUOTED],
[AC_DEFINE_TRACE([$1])dnl
m4_ifval([$3], [AH_TEMPLATE([$1], [$3])])dnl
cat >>confdefs.h <<_ACEOF
address@hidden:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
_ACEOF
])

------------------------------------






reply via email to

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