change log for rtems (2010-04-25)

Joel Sherrill joel.sherrill at OARcorp.com
Tue Apr 27 11:42:03 UTC 2010


On 04/27/2010 01:34 AM, Ralf Corsepius wrote:
> On 04/27/2010 08:21 AM, Chris Johns wrote:
>> On 26/04/2010 1:31 PM, Ralf Corsepius wrote:
>>>>
>>>> - srand (0x23984237);
>>>> + srand (0x23984237UL);
>>>
>>> This change is wrong.
>>>
>>> srand takes an "unsigned int", not an "unsigned long" as argument:
>>>
>>> void srand(unsigned int seed);
>>>
>>> =>  For the code to be portable, this constant's value needs to be
>>> "shortened".
>>>
>>
>> Would this code be ok ?
>>
>> if (sizeof (unsigned int) == 4)
>>    srand (0x23984237);
>> else
>>    srand (0x2398);
> I haven't tried, but I doubt it.
>
> I would expect the compiler to complain on "0x23984237" in "srand
> (0x23984237)" to be too large to fit into an "int" on targets with
> sizeof(int)<  4 at compile-time.
>
I agree this is what the compiler would do.
> [I had tried a similar approach wrt. off_t and had encountered such
> issues there.]
Any other suggestions?   Would this work?

#if (INT_MAX > 65535)
srand (0x23984237);
#else
srand (0x2398);
#endif
>
> Ralf
>
>
>




More information about the vc mailing list