This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bad macros in gcc


There are quie a few macros in gcc like

#define FOO(BAR) \
  do \
    { \
      int s;
      for (s, ....) \
        .. BAR... \
    } \
  while (0)

The problem is when you use FOO with

  for (s = 0; s < 10; s++)
    FOO (foo[s]);

gcc will build, but you will get random runtime errors. In glibc, we
always do

#define FOO(BAR) \
  do \
    { \
      int __s;
      for (__s, ....) \
        .. BAR... \
    } \
  while (0)
  
Shouldn't gcc do something like that or turn FOO into a function?


H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]