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;

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

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

More information about the Newlib mailing list