Bug: _REENT_INIT_PTR() macro argument needs parentheses

Jeff Johnston jjohnstn@redhat.com
Tue May 20 18:01:00 GMT 2008


Peter W. Richards wrote:
> 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 = ...
>
>
>   
Done.

-- Jeff J.
>
>
>
>   



More information about the Newlib mailing list