problem in ppc-linux-gcc cross compiler.

3 messages, 2 authors, 2003-03-05 · open the first message on its own page

problem in ppc-linux-gcc cross compiler.

From: Omanakuttan <hidden>
Date: 2003-03-04 17:02:25

I am not very sure if this is off topic.
I am facing a problem in variable argument passing in linux-gcc-ppc.

[om@pandatest1 ~/prg]$ cat macro2.c
#define __KERNEL__
#define bet_syslog(warning, format, msg...)\
do \
{ \
         printk( "<%d> In file %s, line %d, function %s(). " format "\n",\
              warning, __FILE__, __LINE__, __FUNCTION__, ##msg) ;\
} while (0)

void hell()
{
     bet_syslog(1,"Test Message - 1");
     bet_syslog(2,"Test Message - 2%d",100);
     return ;
}

[om@pandatest1 ~/prg]$ ppc-linux-gcc  -E macro2.c
# 1 "macro2.c"
void hell()
{
     do { printk( "<%d> In file %s, line %d, function %s(). "  "Test
Message - 1"  "\n",  1 , "macro2.c", 11,  ) ;} while (0) ;
     do { printk( "<%d> In file %s, line %d, function %s(). "  "Test
Message - 2%d"  "\n",  2 , "macro2.c", 12, __FUNCTION__,100 ) ;} while (0) ;
     return ;
}
[om@pandatest1 ~/prg]$ ppc-linux-gcc  -v
ppc-linux-gcc: Actual path = '/opt/hardhat/previewkit/ppc/82xx/bin/'
         Actual name = 'ppc_82xx-gcc'
         Invoking
/opt/hardhat/previewkit/ppc/82xx/bin/../lib/gcc-lib/powerpc-hardhat-linux/2.95.3/ppc_82xx-gcc
Reading specs from
/opt/hardhat/previewkit/ppc/82xx/bin/../lib/gcc-lib/powerpc-hardhat-linux/2.95.3/specs
gcc version 2.95.3 20010315 (release/MontaVista)
[om@pandatest1 ~/prg]$


In the first message, __FUNCTION__ is missing and one `,` is extra.
Because of this, it will not compile, stating a parse error.
I am using monta vista linux.

Thanks in acvance.
Om.


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

Re: problem in ppc-linux-gcc cross compiler.

From: Vladimir Gurevich <hidden>
Date: 2003-03-04 18:04:05

Hello,

You should change the line
             warning, __FILE__, __LINE__, __FUNCTION__, ##msg) ;\
to
             warning, __FILE__, __LINE__, __FUNCTION__ , ##msg) ;\
This space (after __FUNCTION__) will do the trick.

You can read more about it in gcc info file (C Extensions/Macro Varargs),
where the issue is thoroughly explained:

       This is a special feature of the GNU C preprocessor: `##' before a
       rest argument that is empty discards the preceding sequence of
       non-whitespace characters from the macro definition.  (If another
       macro argument precedes, none of it is discarded.)


Hope, this helps.
Vladimir


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

Re: problem in ppc-linux-gcc cross compiler.

From: Omanakuttan <hidden>
Date: 2003-03-05 05:07:58

Greetings Mr. Vladimir Gurevich,
Thank you very much. I came across these lines in the info page, but I
could not understand the meaning, which is pretty clear now.
It works.
Thanks a lot,
have a great day,
Om.

Vladimir Gurevich wrote:
Hello,

You should change the line
quoted
             warning, __FILE__, __LINE__, __FUNCTION__, ##msg) ;\
to
quoted
             warning, __FILE__, __LINE__, __FUNCTION__ , ##msg) ;\

This space (after __FUNCTION__) will do the trick.

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help