Welcome, Guest. Please login or register.

Author Topic: Possible C preprocessor bug in VBCC...  (Read 3230 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
Possible C preprocessor bug in VBCC...
« on: March 28, 2007, 10:39:25 PM »
I've stripped down (with many sweat, blood and almost tears, macro debugging is not for the fainthearted I tell you:() an error I was having in a big complicated macro I'm doing to the code bellow. It runs perfectly in SASC(68k) but not on VBCC, wich complains about an invalid created token. Don't have GCC installed to try but it worked on a PC with Borland compiler;).

So, can someone confirm if this is a bug in VBCC, a nonstandard feature that SASC and Borland's preprocessors happend to have, or what ? Asking this as I want the macro to run on any C compliant compiler (whatever that means:)).

Oh, and since we're at it maybe someone could also try it on GCC, I don't fell like installing it.

Cheers fellow coders :pint:

Code: [Select]

#include<stdio.h>

#define EXTRACTBRCKTELMNT(Terminator, Elmnt) #Elmnt, #Terminator

#define GETBRCKTELMNT(ToExtract) GETELMNTEXPAND(EXTRACTBRCKTELMNT##ToExtract)
#define GETELMNTEXPAND(a) GETELMNTEXPAND2 (a)
#define GETELMNTEXPAND2(a, b) a, b


int main (int argc, char **argv)
{ printf(&quot;%s %s\n&quot;, GETBRCKTELMNT((YYY, XXX)));
 
  getchar();
  return (0);
}

\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
Re: Possible C preprocessor bug in VBCC...
« Reply #1 on: March 30, 2007, 09:46:10 AM »
@Karlos
" I think you can get VBCC to show you the emitted C code after the preprocessing stage (just as you can get it to show you the asm before and after going through the instruction scheduler)"

The -E option, doesn't allways work as expected...

"I'll give it a try in a few different compilers tomorrow if I get a minute at work "

Cool:)

"That said, preprocessor behaviour tends to be well defined in the majority of cases.. "

I know that at least C99 finally "standardized" varargs macros so there must be some standard.

@CannonFodder

Yes, that's the expected result (on 2.95.3/MOS that is)



So can this be considered a preprocessor bug because obviously I'm not pasting "EXTRACTBRCKTELMNT" and "(", but "EXTRACTBRCKTELMNT" and "(YYY, XXX)" wich IS a valid token  :getmad:
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
Re: Possible C preprocessor bug in VBCC...
« Reply #2 on: March 30, 2007, 08:40:27 PM »
The C Preprocessor for GCC (Richard Stallman)

I've read this a while ago (the parts about Macros and Pitfalls and Subtleties of Macros) and can't see why it shouldn't work.
Have you tried with different compilers at work ? Should be interesting...8-)

:pint:
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
Re: Possible C preprocessor bug in VBCC...
« Reply #3 on: March 30, 2007, 08:59:08 PM »
Right, thx for testing it. I'm gonna check where in the GCC dev forums I should submit this...
\\"We made Amiga, they {bleep}ed it up\\"