Re: PATCH: gcc3.x __FUNCTION__ fix



On Sun, 2002-01-06 at 21:59, Pawel Salek wrote:
> What about
> #ifdef C99
> #define __FUNCTION__ __func__
> #endif
> or conversely:
> #ifndef C99
> #define __func__ __FUNCTION__
> #endif

hmm no seriously not that way... i dont think its a good idea redefining
constant stuff like this new... e.g. an advanced programmer expects that
__FUNTION__ does exactly what its meant to do and dont get in mind that
there is a redefinition. e.g. redefining __func__ with __FUNCTION__ or
vice versa is no good idea.

what does the gcc 2.95.x info manuals say about this ? e.g. is there a
note that __FUNCTION__ can be substituted with __func__ ?? i havent have
the old compiler anymore so i cant verify.

> I tried to make a test using __STDC_VERSION__ that according to the doc 
> should expand to the implemented standard date but my gcc apparently does 
> not define it.

no, doesnt work with gcc3.0.3 but how about this. its more a quick case
study and ripoff of galeons code. need some rework too but all in all a
suitable solution.

;---[ cut configure.in ]------------------------------------------

dnl ====================================
dnl = End setup gconf schemas installation
dnl ====================================

dnl $1 = regex search prefix
dnl $2 = version string to parse
dnl $3 = name of var to set result
AC_DEFUN(GALEON_PARSE_VERSION,[
	_gpv_pfx=$1
	_gpv_vstr=$2
	# Solaris sed doesn't recognize \+, so use \{1,\} instead
	[_gpv_ver=`echo $_gpv_vstr | sed -n 's/^'${_gpv_pfx}'\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\).*$/\1*16777216+\2*65536+\3*256/p'`]
	if test -z "$_gpv_ver" ; then
		[_gpv_ver=`echo $_gpv_vstr | sed -n 's/^'${_gpv_pfx}'\([0-9]\{1,\}\)\.\([0-9]\{1,\}\).*$/\1*16777216+\2*65536/p'`]
	fi
	if test -n ["`echo $_gpv_vstr | sed -n 's/^'${_gpv_pfx}'[0-9.]\{1,\}+.*$/true/p'`"] ; then
		_gpv_ver="${_gpv_ver}+1"
	fi
	
	if test -z "$_gpv_ver" ; then 
		_gpv_ver="0"
	fi
	$3=`awk "BEGIN{ print $_gpv_ver; exit 0 }"`

])

dnl $1 = version int to parse
AC_DEFUN(GALEON_VERSION_RESULT,[
	# Solaris awk requires exit 0 to exit correctly instead of hanging
	_gvr_ver=$1
	[_gvr_ver_str=`awk "BEGIN{ a = int($_gvr_ver / 16777216); b = int($_gvr_ver / 65536 % 256); c = int($_gvr_ver / 256 % 256); d = int($_gvr_ver % 256); plus[0]=\"\"; plus[1]=\"+\"; printf \"%d.%d.%d%s\n\", a, b, c, plus[d]; exit 0 }"`]
	AC_MSG_RESULT($_gvr_ver_str)
])

dnl Test gcc version
if test "x$GCC" = "xyes"; then
	VER=`gcc --version`
	AC_MSG_CHECKING(for gcc version)
	GALEON_PARSE_VERSION("",$VER,GCC_VERSION)
	GALEON_VERSION_RESULT($GCC_VERSION)
else
	GCC_VERSION=0
fi

AC_DEFINE_UNQUOTED(GCC_VERSION, $GCC_VERSION)

;---[ cut configure.in ]------------------------------------------





;---[ cut acconfig.h ]--------------------------------------------

#undef GCC_VERSION

;---[ cut acconfig.h ]--------------------------------------------





;---[ cut main.c ]------------------------------------------------

#if (GCC_VERSION < VERSION2(3,0))
#  define FUNCTION __FUNCTION__
#else
#  define FUNCTION __func__
#endif

;---[ cut main.c ]------------------------------------------------

-- 
Name....: Ali Akcaagac
Status..: Student Of Computer & Economic Science
E-Mail..: mailto:ali.akcaagac@stud.fh-wilhelmshaven.de
WWW.....: http://www.fh-wilhelmshaven.de/~akcaagaa




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