change log for rtems (2010-04-25)
Ralf Corsepius
ralf.corsepius at rtems.org
Tue Apr 27 06:34:31 UTC 2010
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 had tried a similar approach wrt. off_t and had encountered such
issues there.]
Ralf
More information about the vc
mailing list