[Bug preprocessor/89373] macro expansion not counting braces correctly

2024-04-15 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89373

Andrew Pinski  changed:

   What|Removed |Added

 CC||willisahershey at gmail dot com

--- Comment #5 from Andrew Pinski  ---
*** Bug 114726 has been marked as a duplicate of this bug. ***

[Bug preprocessor/89373] macro expansion not counting braces correctly

2019-02-18 Thread mdblack98 at yahoo dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89373

--- Comment #4 from mdblack98 at yahoo dot com ---
FYI...the variadic macro __VA_ARGS__ did solve the braced items problem on
array initialization in nested macros.  Just have to move the argument to the
end of the macro...

Thanks

Mike

[Bug preprocessor/89373] macro expansion not counting braces correctly

2019-02-17 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89373

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #3 from Jonathan Wakely  ---
You can use a variadic macro that allows multiple preprocessor tokens separated
by commas.

There's no GCC bug here.

[Bug preprocessor/89373] macro expansion not counting braces correctly

2019-02-16 Thread mdblack98 at yahoo dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89373

mdblack98 at yahoo dot com changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |---

--- Comment #2 from mdblack98 at yahoo dot com ---
So how does one get this to compile then..Can't seem to find any combination of
parentheses that works.  I'm converting an entry in the hamlib project to an
array and that's what is causing this problem with static initialization of the
array.

x3.c:10:26: error: braced-group within expression allowed only inside a
function
   FRQ_RNG_160m_REGION##r((m), (lp), (hp), (v), (a))
  ^
x3.c:6:25: note: in definition of macro ‘FRQ_RNG_160m_REGION1’
 { 1810, 2, (md), (lp), (hp), (v), (a) }
 ^~
x3.c:21:20: note: in expansion of macro ‘FRQ_RNG_HF’
 struct foo myfoo = FRQ_RNG_HF(1, MYLIST, 5,100,1,1);
^~


#include 

#define MYLIST {1,2,3,4,5}

#define FRQ_RNG_160m_REGION1(md,lp,hp,v,a) \
{ 1810, 2, (md), (lp), (hp), (v), (a) }


#define FRQ_RNG_HF(r,m,lp,hp,v,a) \
  FRQ_RNG_160m_REGION##r((m), (lp), (hp), (v), (a))

struct foo {
  int i1;
  int i2[64];
  int i3;
  int i4;
  int i5;
  int i6;
};

struct foo myfoo = FRQ_RNG_HF(1, MYLIST, 5,100,1,1);

int
main()
{
  for(int i=0;i<5;++i) printf("kk %d,%d\n",i,myfoo.i2[i]);
  return 0;
}

[Bug preprocessor/89373] macro expansion not counting braces correctly

2019-02-15 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89373

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
  Component|c   |preprocessor
 Resolution|--- |INVALID

--- Comment #1 from Andrew Pinski  ---
In the C preprocessor without a '(' everything after the ',' is the next
argument.