simple (silly) debug output with VBCC

7 posts / 0 new
Last post
jabirulo
jabirulo's picture
Offline
Last seen: 4 days 17 hours ago
Joined: 2013-05-30 00:53
simple (silly) debug output with VBCC

Hi in GCC I use:
#define DBUG(x,...) DebugPrintF("[%s:%-4ld] "x ,__FILE__,__LINE__, ##__VA_ARGS__)

examples:
DBUG("OpenAboutWindow() - START\n");
DBUG(" Licence path:'%s'\n",lic_path);

but under VBCC it complains "error 273 in line 185 of "main.c": not enough arguments to macro"

I can't find a valid replacement for ##__VA_ARGS__ (or wherever problem is)

any help would be appreciated :-)

thomas
thomas's picture
Offline
Last seen: 3 weeks 2 days ago
Joined: 2011-05-16 14:23
Re: simple (silly) debug output with VBCC

Try with -c99 command line option.

jabirulo
jabirulo's picture
Offline
Last seen: 4 days 17 hours ago
Joined: 2013-05-30 00:53
Re: simple (silly) debug output with VBCC

In the makefile the compiler flags used are:
cflags = -c99 -warn=-1 -dontwarn=79,81,163,164,166,167,168,306,307 -D__USE_INLINE__ -ISDK:local/common/include -D__USE_OLD_TIMEVAL__ -D__USE_CLASSIC_MINTERM__ -D__AMIDATE__="$(AMIDATE)" $(DEBUG)

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
thomas
thomas's picture
Offline
Last seen: 3 weeks 2 days ago
Joined: 2011-05-16 14:23
Re: simple (silly) debug output with VBCC

Seems like VBCC requires at least one argument for "..." and it does not like ## there.

If you remove ## and add ,0 to the first DBUG call, then it compiles.

jabirulo
jabirulo's picture
Offline
Last seen: 4 days 17 hours ago
Joined: 2013-05-30 00:53
Re: simple (silly) debug output with VBCC

THX removed ## and added 'NULL' argument to "empty" DBUG calls, noticed that last thing too since a few new SDK test builds.

Now working fine with VBCC "DBUG()". Thanks mate

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
salass00
salass00's picture
Offline
Last seen: 2 months 2 days ago
Joined: 2011-02-03 11:27
Re: simple (silly) debug output with VBCC

This use of '##' to remove the comma if the varargs parameter doesn't exist is AFAIK a gcc specific extension to the C language and not part of ANSI C, which is why it's not supported by vbcc.

The inline4 macros for Printf() and other varargs functions get around this by including the last regular argument into the varargs argument, e.g.:
#define Printf(...) IDOS->Printf(__VA_ARGS__)
instead of
#define Printf(fmt, ...) IDOS->Printf((fmt), ## __VA_ARGS__)

jabirulo
jabirulo's picture
Offline
Last seen: 4 days 17 hours ago
Joined: 2013-05-30 00:53
Re: simple (silly) debug output with VBCC

ok, thx understood.

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
Log in or register to post comments