linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* problem in ppc-linux-gcc cross compiler.
@ 2003-03-04 17:02 Omanakuttan
  2003-03-04 18:04 ` Vladimir Gurevich
  0 siblings, 1 reply; 3+ messages in thread
From: Omanakuttan @ 2003-03-04 17:02 UTC (permalink / raw)
  To: linuxppc-embedded


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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem in ppc-linux-gcc cross compiler.
  2003-03-04 17:02 problem in ppc-linux-gcc cross compiler Omanakuttan
@ 2003-03-04 18:04 ` Vladimir Gurevich
  2003-03-05  5:07   ` Omanakuttan
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Gurevich @ 2003-03-04 18:04 UTC (permalink / raw)
  To: Omanakuttan; +Cc: linuxppc-embedded


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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem in ppc-linux-gcc cross compiler.
  2003-03-04 18:04 ` Vladimir Gurevich
@ 2003-03-05  5:07   ` Omanakuttan
  0 siblings, 0 replies; 3+ messages in thread
From: Omanakuttan @ 2003-03-05  5:07 UTC (permalink / raw)
  To: Vladimir Gurevich; +Cc: linuxppc-embedded


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
>
>>              warning, __FILE__, __LINE__, __FUNCTION__, ##msg) ;\
>
> to
>
>>              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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-03-05  5:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-04 17:02 problem in ppc-linux-gcc cross compiler Omanakuttan
2003-03-04 18:04 ` Vladimir Gurevich
2003-03-05  5:07   ` Omanakuttan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).