D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20600 - C++ header output `-HC` can't write size_t correctly
Summary: C++ header output `-HC` can't write size_t correctly
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-23 02:33 UTC by Manu
Modified: 2020-11-07 16:15 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Manu 2020-02-23 02:33:00 UTC
Is it possible in DMD FE to detect that a type was declared as size_t? We need to be able to detect this in order to emit the proper type back to the .h file (and I suspect this same issue applies to .di files too)
Comment 1 Jacob Carlborg 2020-02-23 09:43:31 UTC
It looks like `core.stdc.config.cpp_size_t` is supposed to be used to get the correct size and mangling on all platforms. The compiler specially recognizes `__c_long` and a couple of more symbols related to C and C++ interoperability, see [1] for all of them.

[1] https://github.com/dlang/dmd/blob/89d0cd492a5284ab67f665f3014b73905aecb4e2/src/dmd/id.d#L126-L131
Comment 2 Manu 2020-02-23 21:32:43 UTC
I'm not sure how what you're saying relates to size_t?
I notice that when I use size_t in code, the type seems to be lost; is it just an alias for a sized integer? It needs to retain the fact that it was specified as size_t in the AST somehow.
Comment 3 moonlightsentinel 2020-11-07 16:15:04 UTC
Fixed in https://github.com/dlang/dmd/pull/10862