On Saturday, 1 November 2014 at 15:00:57 UTC, Shriramana Sharma via Digitalmars-d-learn wrote:
In the following pages:

http://dlang.org/interfaceToC.html
http://dlang.org/cpp_interface

the "Data Type Compatibility" section says D int is compatible with C/C++ int. Isn't this actually false because D's integer types are fixed-size whereas C/C++'s are variable? So D int is only compatible with C++ int32_t, and who knows what that is typedef-ed to? Likewise
for uint, long, short etc.

So how to ensure, when calling C/C++, that the D int etc are being mapped to the correctly-sized C/C++ type? Does the compiler ensure
that since the compatibility is being advertised as built-in?

Note this at the end of the "Data Type Compatiblity" section:

"These equivalents hold for most C compilers. The C standard does not pin down the sizes of the types, so some care is needed."

D's built-in types do not change based on the companion C compiler. When linking to C, it is the programmers responsibility to ensure they are using the right types.

core.stdc.config can help deal with the most common inconsistencies.

Reply via email to