Skip to content

Use c_schar instead of c_char #559

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

Merged
merged 1 commit into from
Mar 6, 2017
Merged

Conversation

pyropeter
Copy link
Contributor

The signedness of the C type 'char' is implementation defined. The
rust type c_schar exists for this reason. Use it.

The signedness of the C type 'char' is implementation defined. The
rust type c_schar exists for this reason. Use it.
@nox
Copy link
Contributor

nox commented Mar 5, 2017

The type c_schar is always signed, whereas c_char's signedness is implementation-defined. Where did you read that c_schar was to be used for the equivalent of C's char type?

@pyropeter
Copy link
Contributor Author

I didn't. But bindgen uses c_char for clangs CXType_SChar, which is obviously a signed char.

@nox
Copy link
Contributor

nox commented Mar 5, 2017

That sounds wrong indeed. It seems like IntKind should have an additional variant SChar.

@emilio
Copy link
Contributor

emilio commented Mar 5, 2017

That sounds wrong indeed. It seems like IntKind should have an additional variant SChar.

That's right. Please update the PR to do that instead, thanks!

@pyropeter
Copy link
Contributor Author

pyropeter commented Mar 6, 2017

Why do you want to have an additional variant SChar in IntKind? As far as I understand, clang takes care of the ugly char type and only uses signed char and unsigned char afterwards, so there really is no need for a variant representing char, is there?

One could of course rename the Char variant to SChar, but that would break the naming scheme of your variants. In that case I would prefer to add an explicit S prefix to all signed variants. (Like it is done in clang)

@emilio
Copy link
Contributor

emilio commented Mar 6, 2017

Why do you want to have an additional variant SChar in IntKind? As far as I understand, clang takes care of the ugly char type and only uses signed char and unsigned char afterwards, so there really is no need for a variant representing char, is there?

Whoops, you're totally right here. My memory failed me and I thought that there was a CXType_Char, but apparently there isn't, so this looks fine to me.

@bors-servo r+

@bors-servo
Copy link

📌 Commit 4f1e3da has been approved by emilio

@bors-servo
Copy link

⌛ Testing commit 4f1e3da with merge 1a4b8e6...

bors-servo pushed a commit that referenced this pull request Mar 6, 2017
Use c_schar instead of c_char

The signedness of the C type 'char' is implementation defined. The
rust type c_schar exists for this reason. Use it.
@bors-servo
Copy link

☀️ Test successful - status-travis
Approved by: emilio
Pushing 1a4b8e6 to master...

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

Successfully merging this pull request may close these issues.

5 participants