Re: uint64_t error and architecture targets
Re: uint64_t error and architecture targets
- Subject: Re: uint64_t error and architecture targets
- From: Jean-Daniel Dupas <email@hidden>
- Date: Fri, 11 Feb 2011 10:48:48 +0100
Le 11 févr. 2011 à 09:55, Andreas Grosam a écrit :
>
> On Feb 11, 2011, at 2:36 AM, Clark S. Cox III wrote:
>
>>
>> On Feb 10, 2011, at 5:28 PM, Todd Heberlein wrote:
>>
>>> In C++ code I have a line like:
>>>
>>> uint64_t y = 0xffffffffffffffffUL;
>>>
>>> This compiles fine when I have the architecture set to "Build Active Architecture Only". But if I uncheck this box, I get an error with the message "Integer constant is too large for 'unsigned long' type."
>>
>> The "UL" at the end of your literal indicates that you want it to be (unsigned long). On 32-bit, that isn't possible, and that is what the compiler is telling you. Use "ULL".
>>
>> On the other hand, a convenient way to get the maximum value into an unsigned variable, regardless of its size is to use -1"
>>
>> uint64_t y = -1;
>
> In C++ I would prefer to write
>
> #include <limits>
> #include <stdint.h>
>
> uint64_t y = std::numeric_limits<uint64_t>::max();
>
agree, and in C, it should by
uint64_t y = UINT64_MAX;
-- Jean-Daniel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden