This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Bug: _REENT_INIT_PTR() macro argument needs parentheses
- From: "Peter W. Richards" <peter dot richards at tagarray dot com>
- To: <newlib at sources dot redhat dot com>
- Date: Wed, 14 May 2008 14:07:42 -0700
- Subject: Bug: _REENT_INIT_PTR() macro argument needs parentheses
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 = ...