Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sizeof int #683

Closed
kamphaus opened this issue Apr 20, 2018 · 3 comments
Closed

Sizeof int #683

kamphaus opened this issue Apr 20, 2018 · 3 comments

Comments

@kamphaus
Copy link
Contributor

In c we have sizeof(int) == 4.
However in Go the size of int is platform dependent, it could be either 4 or 8 bytes.
cf. https://golang.org/ref/spec#Numeric_types

How should we handle this?
Should every int be translated as int32 to be platform independent?

@kamphaus
Copy link
Contributor Author

This issue has repercussions in every part we use sizeof(int):

  • pointer arithmetic Pointer arithmetic #146
  • code that needs to use sizeof a struct type (could have int fields):
    e.g. in 3593314 to be able to memset a struct with int field we need the correct size of ints (on my machine it was 8 bytes).

@elliotchance
Copy link
Owner

Yes, that's a good point. My first thought it to disallow int in the Go at all. Instead have C int always resolve to Go's int32?

@kamphaus
Copy link
Contributor Author

My thought as well.
I'll try to implement it that way and I will create a PR when done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants