Skip to contentSkip to conversation

__FUNCTION__ revisited

parisc-linux Grant Grundler 2 participants 3 messages Oct 26, 2000 – Oct 27, 2000

lore
Share & tools
lore
#0 lore raw

Hi Ulrich,

After RTFMing for a bit, I still think __FUNCTION__ is b0rken. Maybe I'm doing something else stupid that's obvious to you.

In linux/arch/parisc/kernel/sba_ccio.c I have some debug output which can be enabled like this:

	#define DEBUG_SBA_RUN_SG

I use that for:

	#ifdef DEBUG_SBA_RUN_SG
	#define DBG_RUN_SG(x...)       printk(x)
	#else
	#define DBG_RUN_SG(x...)
	#endif

and use DBG_RUN_SG() like this:

	DBG_RUN_SG("%s() DONE %d mappings\n", __FUNCTION__, n_mappings);

The output I get looks like "() DONE 16 mappings". No complaints from compiler or linker.

And despite the official change of __FUNCTION__'s data type almost 2 years ago in the developement branch, __FUNCTION__ was still being treated as a literal by our tool chain as late as August 3, 2000.
I still have the c110 console output to prove it:
-rw-rw---- 1 grundler users 12384 Aug 3 19:35 c110.out1

thanks,
grant

#1 lore raw
Quoted 4 lines · Grant Grundler
	DBG_RUN_SG("%s() DONE %d mappings\n", __FUNCTION__, n_mappings);

The output I get looks like "() DONE 16 mappings". No complaints from compiler or linker.

Here's a weird datapoint.

cat > xxx.c <<EOF
#include <stdio.h>

#define DEBUG_SBA_RUN_SG

#ifdef DEBUG_SBA_RUN_SG
#define DBG_RUN_SG(x...) printf(x)
#else
#define DBG_RUN_SG(x...)
#endif

int foo (int i)
{
DBG_RUN_SG("%s() DONE %d mappings\n", __FUNCTION__, i); return i;
}

int main (void)
{
return foo (0);
}
EOF
hppa-linux-gcc -S -O2 -o xxx.s xxx.c

shows that __FUNCTION__ is being translated as an empty string. The really weird bit is that if you remove "#include <stdio.h>", everything is OK!

Alan Modra

Signature · 1 line
Linuxcare.  Support for the Revolution.
#2 lore raw
Quoted 3 lines · Alan Modra

shows that __FUNCTION__ is being translated as an empty string. The really weird bit is that if you remove "#include <stdio.h>", everything is OK!

Seems to be related to the swag of __inline functions you get from bits/stdio.h. Editting a .i to remove them cures the problem. Gack, yet another compiler bug - in yesterday's hppa64-hpux CVS gcc from sourceware too.

Alan Modra

Signature · 1 line
Linuxcare.  Support for the Revolution.