[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature: C preprocessor supports __func__ or __FUNCTION__?
From: |
R. Bernstein |
Subject: |
Re: Feature: C preprocessor supports __func__ or __FUNCTION__? |
Date: |
Sun, 14 Jul 2002 09:12:54 -0400 |
> > should I try to supply
> > a patch to provide such a feature?
>
> Sure!
Will be heading out on vacation shortly and will probably finish when
I get back. However the below is a rough cut. The AC_TRY_COMPILE
should be folded into the AC_COMPILE_IFELSE so that if __FUNCTION__ is
selected the message on AC_COMPILE_IFELSE reports that. I don't have
the mastery of m4 or autoconf to know how to do yet.
I what is below would go in c.m4, however personally I think it would
be cleaner to put this in a separate m4, e.g. cpp.m4. AC_C_STRINGIZE
would also get moved there since again this is a C preprocessor thing,
not a C thing. And also, I'd change the name of that to
AC_CPP_STRINGIZE.
Thanks folks!
# ------------------ #
# The C Preprocessor #
# ------------------ #
# AC_CPP_FUNC
# ------------------ #
AC_DEFUN([AC_CPP_FUNC],
[AC_REQUIRE([AC_PROG_CC_STDC])dnl
AC_CACHE_CHECK([for an ANSI C99-conforming __func__], ac_cv_cpp_func,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
[[char *foo = __func__;]])],
[ac_cv_cpp_func=yes],
[ac_cv_cpp_func=no])])
if test $ac_cv_cpp_func = no; then
AC_TRY_COMPILE([],
[char *foo = __FUNCTION__;],
[ac_cv_cpp_func=__FUNCTION__],
[ac_cv_cpp_func=no])
fi
if test $ac_cv_cpp_func = __FUNCTION__; then
AC_DEFINE(__func__,__FUNCTION__,
[Define to __FUNCTION__ or "" if `__func__' does not conform to
ANSI C.])
elif test $ac_cv_cpp_func = no; then
AC_DEFINE(__func__,"",
[Define to __FUNCTION__ or "" if `__func__' does not conform to
ANSI C.])
fi
]) # AC_CPP_FUNC