This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: make real.h constants more consistent
2008/8/12 Ian Lance Taylor <iant@google.com>:
> "Manuel López-Ibáñez" <lopezibanez@gmail.com> writes:
>
>> 2008/8/12 Ian Lance Taylor <iant@google.com>:
>>> "Manuel López-Ibáñez" <lopezibanez@gmail.com> writes:
>>>
>>>> +#define dconst_e (*get_real_const_e ())
>>>> +#define dconst_third (*get_real_const_third ())
>>>> +#define dconst_sqrt2 (*get_real_const_sqrt2 ())
>>>
>>> I don't like hiding a function call inside what appears to be a
>>> variable reference. I would rather have the code explicitly call a
>>> function. If you like, have that function return REAL_VALUE_TYPE--
>>> that shouldn't introduce any real inefficiency in practice.
>>
>> I don't think that will work since in some places we need to use a
>> pointer to REAL_VALUE_TYPE and then if get_real_const_e() returns
>> REAL_VALUE_TYPE, we cannot call &get_real_const_e(). However, with the
>> current definitions &(*get_real_const_e()) is ok. Or am I
>> misunderstanding something here?
>
> I'm fine with returning a pointer, too, I just thought you wanted
> something that looked a little nicer.
I do!! Actually, it is not for niceness but for consistency with the
other constants. I simply don't see how to make your proposal work or
any other way than using a macro (which you don't like).
What about:
#define dconst_e() (*get_real_const_e ())
then we could do &dconst_e() safely (would that look weird?).
Cheers,
Manuel.