Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd a type which is equivalent to _Bool in C99 #992
Comments
alexcrichton
added
the
A-libs
label
Mar 19, 2015
alexcrichton
referenced this issue
Mar 19, 2015
Closed
Specify that `bool` is compatible with the `_Bool` C type. #954
comex
referenced this issue
Nov 4, 2016
Closed
Create a separate libc_types crate for basic C types #1783
steveklabnik
referenced this issue
Nov 29, 2016
Closed
Is bool FFI compatible, and if so, what is it defined to be? #14608
This comment has been minimized.
This comment has been minimized.
Timmmm
commented
Dec 2, 2016
•
|
Did this ever happen? What should I do if I'm wrapping a C library that uses Edit: Never mind; seems it is still in the works but according to this comment all compilers/systems that you'd care about make |
This comment has been minimized.
This comment has been minimized.
|
I would argue that we should define Rust's |
This comment has been minimized.
This comment has been minimized.
Yamakaky
commented
Dec 2, 2016
•
|
Wouldn't it prevent the compiler to do things like pack 8 bool in a byte? Or does |
This comment has been minimized.
This comment has been minimized.
|
@Yamakaky Packing like that would have to be opt-in because you can take references to any fields. |
This comment has been minimized.
This comment has been minimized.
Timmmm
commented
Dec 3, 2016
|
Well, I'm not a rust pro, but I'd be happy with a |
This comment has been minimized.
This comment has been minimized.
|
There are basically 2 ways to define
#[repr(i8)]
enum c_bool {
c_false = 0,
c_true = 1,
}The first one is easier to use, but ties our representation of |
This comment has been minimized.
This comment has been minimized.
|
@Amanieu I think that tying our representation of |
federicomenaquintero
referenced this issue
Apr 26, 2017
Closed
Want a compiler warning if I repr(C) a bool #1982
gnomesysadmins
pushed a commit
to GNOME/librsvg
that referenced
this issue
Apr 26, 2017
This comment has been minimized.
This comment has been minimized.
le-jzr
commented
Apr 27, 2017
|
I feel like this issue needs to be resolved. Currently there is no stable way to use |
This comment has been minimized.
This comment has been minimized.
|
@le-jzr it's already de facto resolved (and basically de jure resolved). There's no way to change it without silently breaking a ton of code. |
This comment has been minimized.
This comment has been minimized.
|
It's just a matter of adding |
This comment has been minimized.
This comment has been minimized.
le-jzr
commented
Apr 28, 2017
|
@ubsan According to #954 (comment), specifying that Note carefully that I'm not saying I'm categorically against that. I'm just saying it hasn't been stabilized yet. That's the principal problem. As long as it's unstable, then de jure that "ton of code" you speak of is a ton of undefined behavior, even though it de facto works right now. That said, according to #954 (comment), the current representation of |
This comment has been minimized.
This comment has been minimized.
|
@le-jzr but it's also allowed in FFI functions without warning (which is close to de jure confirmation). |
est31
added a commit
to est31/rust
that referenced
this issue
Nov 21, 2017
est31
added a commit
to est31/rust
that referenced
this issue
Nov 22, 2017
petrochenkov
added
T-libs
and removed
A-libs
labels
Jan 29, 2018
AndrewGaspar
referenced this issue
Feb 7, 2018
Closed
Consider defining `equivalent_system_datatype!(bool, ffi::RSMPI_C_BOOL);` #34
This comment has been minimized.
This comment has been minimized.
isislovecruft
commented
Apr 23, 2018
•
|
Hi! At @torproject, we recently decided for tor that it's permissible to write C99, and we now have a function returning a bool that I'd like to wrap in an FFI definition for exposure to our Rust code (cf. https://bugs.torproject.org/25727). We've noted that On the other hand, it seems the If the ABI of Is it possible to come to a decision on this issue soon? |
This comment has been minimized.
This comment has been minimized.
|
@isislovecruft I believe that the RFC was closed, and that the representation of bool will be the same as |
This comment has been minimized.
This comment has been minimized.
tlyu
commented
May 15, 2018
|
It looks like @withoutboats proposed basically accepting #954 (at rust-lang/rust#46156 (comment)) and also thinks that Rust's I'm not very familiar with the Rust RFC process, so I'm not sure what needs to happen next if we want this to move forward. Does someone need to reopen #954? Or should someone propose a FCP on this RFC? Or something else? |
alercah
referenced this issue
Sep 8, 2018
Closed
Representation of bool, integers and floating points #9
This comment has been minimized.
This comment has been minimized.
|
It seems to me that given rust-lang/rust#46156 (comment) and other changes noted in #992 (comment) the points in OP are completed. |
alexcrichton commentedMar 19, 2015
Postponed RFC
This type would have to ensure two aspects:
This could possibly be done through a new
c_boolprimitive type inliblibc(not an alias) or perhaps a wrapper struct/wrapper newtype if we're able to enhanceassemantics enough (for example).