Bug: _REENT_INIT_PTR() macro argument needs parentheses

Peter W. Richards peter.richards@tagarray.com
Tue May 20 07:06:00 GMT 2008


Minor bug...but it seems reasonable that one ought to be able to do this:

  struct _reent my_reent;
  _REENT_INIT_PTR(&my_reent);

But it doesn't work because the '->' in the macro has higher precedence than
the '&', giving you, effectively
  &(my_reent->_errno) = ...
Instead of what you want:
  (&my_reent)->_errno = ...

This can be worked around with
  _REENT_INIT_PTR((&my_reent));

But it would be preferable to change the definition of _REENT_INIT_PTR(var)
from
  { var->_errno = ...
To 
  { (var)->errno = ...








More information about the Newlib mailing list