This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Macro Labels in local scope: Works with g++ but breaks with gcc
- From: Rama Singh <rama10nov at yahoo dot co dot in>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 14 Nov 2003 08:13:01 +0000 (GMT)
- Subject: Macro Labels in local scope: Works with g++ but breaks with gcc
Hi,
I s there a way to implement laels in macros for local
scope using GCC. Attached is a code snippet that I am
using in my application. The problem is that I am
using a Macro in which there are labels and jumps to
these labels. Now when this macro is expanded, it
gives duplicate label error.
This code runs fine with g++ but breaks with gcc. Is
it a specific behaviour of the C standard?
I have tried it on g++ 2.96 and 3.2 running on a RH
7.2
If this is a bug, has it been fixed in the latest
release of gcc?
//====Copy Here=========================
#ifdef __cplusplus
#include <iostream>
#else
#include <stdio.h>
#endif
#include <assert.h>
#define CHECK_MACRO(pA,B,C) \
{\
__label__ lbl_1;\
__label__ lbl_2;\
__label__ lbl_3;\
\
*pA = 0; \
\
lbl_1: \
if(B>10) { \
goto lbl_2; \
} \
*pA = 10; \
goto lbl_3; \
lbl_2: \
*pA = B+10; \
if (*pA < 7) \
goto lbl_1; \
lbl_3: \
*pA = C+100; \
}
// Test code for checking the macro operation
int main(int argc, char *argv[])
{
short data1;
short data2;
short data3;
printf(" Test code\n");
data2 = -2;
data3 = 12;
CHECK_MACRO(&data1, data2, data3);
printf(" data1 %d, data2 %d, data3 %d \n", data1,
data2, data3);
data2 = -7;
data3 = 9;
CHECK_MACRO(&data1, data2, data3);
printf(" data1 %d, data2 %d, data3 %d \n", data1,
data2, data3);
printf (" Test completed successfully! \n");
}
==Till Here==============
________________________________________________________________________
Yahoo! India Mobile: Download the latest polyphonic ringtones.
Go to http://in.mobile.yahoo.com