D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6239 - HTOD: Add support for converting opaque C types to D
Summary: HTOD: Add support for converting opaque C types to D
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: tools (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-01 22:24 UTC by Andrej Mitrovic
Modified: 2016-08-27 22:06 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 Andrej Mitrovic 2011-07-01 22:24:57 UTC
E.g.:

typedef struct _cairo_device cairo_device_t;

htod translates this incorrectly to:
alias _cairo_device cairo_device_t;

The closest D idiom to this is:
typedef void cairo_device_t;

Or if typedef is ultimately killed maybe alias would work:
alias void cairo_device_t;

There's a ton of this stuff in C header files. :/
Comment 1 Andrej Mitrovic 2011-07-01 22:27:52 UTC
For what it's worth this helps for us porting monkeys:

regex: alias \w+
replace with: typedef void

But you have to do this manually..
Comment 2 Andrej Mitrovic 2011-07-01 22:33:59 UTC
Well crap that's not good, it needs to be:
typedef void cairo_device_t;
typedef void _cairo_device;

Stupid C APIs!
Comment 3 Mike Parker 2011-07-02 04:05:53 UTC
Wouldn't it be more appropriate to translate it as:

struct cairo_device_t {}
Comment 4 Jacob Carlborg 2011-07-02 06:08:47 UTC
The most correct translation would be:

struct cairo_device_t;
Comment 5 Andrej Mitrovic 2016-08-27 22:06:15 UTC
dstep supports this feature (https://github.com/jacob-carlborg/dstep), marking as wontfix.