[Top][All Lists]

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

Re: finding the value of a preprocessor symbol

From: Ralf Wildenhues
Subject: Re: finding the value of a preprocessor symbol
Date: Sun, 24 Jan 2010 09:45:09 +0100
User-agent: Mutt/1.5.20 (2009-10-28)

Hello David,

* David Byron wrote on Fri, Jan 22, 2010 at 12:38:03AM CET:
> Let's say I have a header file named foo.h that contains:
> #define FOO an_interesting_value
> (I think) I'm looking for a macro like this:
> AC_GET_VALUE([foo.h],[FOO])
> that populates ac_cv_value_of_FOO with an_interesting_value
> Does such a macro exist?  Apologies if this is a FAQ.  I can think of a way
> to do this by compiling a program that writes the result to a file, but that
> seems complicated and a struggle when cross-compiling.

There is AC_COMPUTE_INT which allows you to compute the integer
(signed long) value of an arbitrary compile-time expression.  It is
a bit overkill for your case (in a cross-compile situation, it may
need up to log_2(value) compilations to find the value), but should
work nonetheless.

Autoconf provides AC_EGREP_CPP but that doesn't let you get at the
matched string.  I think we should add something like this, or allow
AC_PREPROC_IFELSE to store its output for inspection in the IF-TRUE

cpp -dM is not portable to non-GCC compilers.

Thanks for the report.


reply via email to

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