Russ Cox <rsc@google.com> writes: > This is gcc. You can use > > typedef unsigned ...
14 years, 6 months ago
(2010-09-07 17:32:38 UTC)
#4
Russ Cox <rsc@google.com> writes:
> This is gcc. You can use
>
> typedef unsigned long uintptr;
Heck, since it's gcc, you can use
typedef __UINTPTR_TYPE__ uintptr;
I don't know if this matters here, but on Windows for 64-bit x86,
unsigned long is 32 bits, and uintptr is 64 bits for which you need
unsigned long long.
Ian
x On 8 September 2010 03:32, Ian Lance Taylor <iant@google.com> wrote: > Russ Cox <rsc@google.com> ...
14 years, 6 months ago
(2010-09-08 05:35:25 UTC)
#5
x
On 8 September 2010 03:32, Ian Lance Taylor <iant@google.com> wrote:
> Russ Cox <rsc@google.com> writes:
>
>> This is gcc. You can use
>>
>> typedef unsigned long uintptr;
>
> Heck, since it's gcc, you can use
>
> typedef __UINTPTR_TYPE__ uintptr;
Using this I get:
_cgo_export.h:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘uintptr’
My /usr/include/stdint.h doesn't refer to UINTPTR_TYPE anywhere.
> I don't know if this matters here, but on Windows for 64-bit x86,
> unsigned long is 32 bits, and uintptr is 64 bits for which you need
> unsigned long long.
If cgo is to work under windows, then should the current version
remain? Otherwise if the above won't work I'll just do
typedef unsigned long uintptr;
Andrew
Andrew Gerrand <adg@golang.org> writes: > x > On 8 September 2010 03:32, Ian Lance Taylor ...
14 years, 6 months ago
(2010-09-08 05:48:39 UTC)
#6
Andrew Gerrand <adg@golang.org> writes:
> x
> On 8 September 2010 03:32, Ian Lance Taylor <iant@google.com> wrote:
>> Russ Cox <rsc@google.com> writes:
>>
>>> This is gcc. You can use
>>>
>>> typedef unsigned long uintptr;
>>
>> Heck, since it's gcc, you can use
>>
>> typedef __UINTPTR_TYPE__ uintptr;
>
> Using this I get:
>
> _cgo_export.h:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> ‘__attribute__’ before ‘uintptr’
>
> My /usr/include/stdint.h doesn't refer to UINTPTR_TYPE anywhere.
Ah, my apologies. That only works with gcc 4.5 or later, so it's not
yet useful for cgo.
>> I don't know if this matters here, but on Windows for 64-bit x86,
>> unsigned long is 32 bits, and uintptr is 64 bits for which you need
>> unsigned long long.
>
> If cgo is to work under windows, then should the current version
> remain? Otherwise if the above won't work I'll just do
>
> typedef unsigned long uintptr;
Another option would be __SIZE_TYPE__ which gcc has supported for quite
a while. In general __SIZE_TYPE__ should give you the right size for a
pointer.
In practice "unsigned long" will be fine except on 64-bit Windows.
Ian
On 8 September 2010 15:48, Ian Lance Taylor <iant@google.com> wrote: > Andrew Gerrand <adg@golang.org> writes: ...
14 years, 6 months ago
(2010-09-08 05:53:28 UTC)
#8
On 8 September 2010 15:48, Ian Lance Taylor <iant@google.com> wrote:
> Andrew Gerrand <adg@golang.org> writes:
>
>> x
>> On 8 September 2010 03:32, Ian Lance Taylor <iant@google.com> wrote:
>>> Russ Cox <rsc@google.com> writes:
>>>
>>>> This is gcc. You can use
>>>>
>>>> typedef unsigned long uintptr;
>>>
>>> Heck, since it's gcc, you can use
>>>
>>> typedef __UINTPTR_TYPE__ uintptr;
>>
>> Using this I get:
>>
>> _cgo_export.h:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
>> ‘__attribute__’ before ‘uintptr’
>>
>> My /usr/include/stdint.h doesn't refer to UINTPTR_TYPE anywhere.
>
> Ah, my apologies. That only works with gcc 4.5 or later, so it's not
> yet useful for cgo.
>
>
>>> I don't know if this matters here, but on Windows for 64-bit x86,
>>> unsigned long is 32 bits, and uintptr is 64 bits for which you need
>>> unsigned long long.
>>
>> If cgo is to work under windows, then should the current version
>> remain? Otherwise if the above won't work I'll just do
>>
>> typedef unsigned long uintptr;
>
> Another option would be __SIZE_TYPE__ which gcc has supported for quite
> a while. In general __SIZE_TYPE__ should give you the right size for a
> pointer.
That works. I've used it instead.
> In practice "unsigned long" will be fine except on 64-bit Windows.
Let's see if __SIZE_TYPE__ works under MinGW I guess.
Andrew
Issue 2102043: code review 2102043: cgo: add typedef for uintptr in generated headers
(Closed)
Created 14 years, 6 months ago by adg
Modified 14 years, 6 months ago
Reviewers:
Base URL:
Comments: 0