2014-09-09 14 views

risposta

6

Che cosa si intende per un sistema operativo a 32 o 64 bit? Ad esempio, GOARCH=amd64p32, che viene utilizzato per GOOS=nacl, è amd64 istruzioni a 64 bit con puntatori a 32 bit e tipo a 32 bit int s e uint s.

package main 

import (
    "fmt" 
    "runtime" 
    "strconv" 
) 

func main() { 
    const PtrSize = 32 << uintptr(^uintptr(0)>>63) 
    fmt.Println(runtime.GOOS, runtime.GOARCH) 
    fmt.Println(strconv.IntSize, PtrSize) 
} 

Playground: http://play.golang.org/p/TKnCA0gqsI

uscita:

nacl amd64p32 
32 32 

e

linux amd64 
64 64 
+0

Vorrei solo sapere IntSize, PtrSize –

+0

@DanielYCLin: se si desidera solo la dimensione di int e puntatori, è possibile utilizzare 'unsafe.Sizeof' – JimB

+0

non sicuro non è corretta. Penso che lo strconv sia migliore. –

Problemi correlati