Skip to content

Commit 01e7d2a

Browse files
authored
Add instructions to find header files. Make C vs. Rust versions of code examples more explicit (#694)
1 parent b86a99b commit 01e7d2a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

CONTRIBUTING.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Guidelines
22

33
* Never get definitions from MinGW headers or MSDN. Always stick to the Windows SDK headers, in
4-
particular the latest Windows 10 SDK.
4+
particular the latest Windows 10 SDK — you can find it [here](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk). Look for a folder called "Include" inside the installed SDK to find the header (and other) files.
55
* Definitions which depend on whether `UNICODE` is defined should not be included. It is the user's
66
responsibility to explicitly choose between `W` and `A` functions (and they should always choose
77
`W`).
@@ -98,9 +98,12 @@ FN!{stdcall NAMEENUMPROCA(
9898
cast must be performed, do the cast using the primitive integer types.
9999
* If the constant is a pointer that is initialized to a negative literal, do `-1isize as LPFOO`.
100100

101+
The C version found in the SDK:
101102
```C
102103
#define CLSCTX_INPROC (CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER)
103104
```
105+
106+
And what the Rust binding should look like:
104107
```Rust
105108
pub const CLSCTX_INPROC: CLSCTX = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER;
106109
```
@@ -116,15 +119,18 @@ DEFINE_GUID!{GUID_DEVCLASS_SENSOR,
116119

117120
## Structs
118121

119-
* One field per line.
122+
Each field must be on its own line.
120123

124+
The C version found in the SDK:
121125
```C
122126
typedef struct _GROUP_AFFINITY {
123127
KAFFINITY Mask;
124128
WORD Group;
125129
WORD Reserved[3];
126130
} GROUP_AFFINITY, *PGROUP_AFFINITY;
127131
```
132+
133+
And what the Rust binding should look like:
128134
```Rust
129135
STRUCT!{struct GROUP_AFFINITY {
130136
Mask: KAFFINITY,
@@ -136,6 +142,7 @@ pub type PGROUP_AFFINITY = *mut GROUP_AFFINITY;
136142

137143
## Unions
138144

145+
The C version found in the SDK:
139146
```C
140147
typedef union {
141148
USN_RECORD_COMMON_HEADER Header;
@@ -144,6 +151,8 @@ typedef union {
144151
USN_RECORD_V4 V4;
145152
} USN_RECORD_UNION, *PUSN_RECORD_UNION;
146153
```
154+
155+
And what the Rust binding should look like:
147156
```Rust
148157
UNION!{union USN_RECORD_UNION {
149158
[u64; 10],
@@ -202,6 +211,7 @@ UNION!{union D3D12_RESOURCE_BARRIER_u {
202211

203212
## Union with a primitive field and an anonymous bitfield struct of the same type
204213

214+
The C version found in the SDK:
205215
```C
206216
typedef union _USB_HUB_STATUS {
207217
USHORT AsUshort16;
@@ -213,6 +223,7 @@ typedef union _USB_HUB_STATUS {
213223
} USB_HUB_STATUS, *PUSB_HUB_STATUS;
214224
```
215225

226+
And what the Rust binding should look like:
216227
```Rust
217228
STRUCT!{struct USB_HUB_STATUS {
218229
AsUshort16: USHORT,
@@ -264,11 +275,13 @@ interface IDWriteFontFileStream(IDWriteFontFileStreamVtbl): IUnknown(IUnknownVtb
264275
* The uuid should always be lowercase hex.
265276
* Uuid numbers should be padded with zeros to ensure consistent width.
266277

278+
The C version found in the SDK:
267279
```C
268280
class DECLSPEC_UUID("D9F6EE60-58C9-458B-88E1-2F908FD7F87C")
269281
SpDataKey;
270282
```
271283

284+
And what the Rust binding should look like:
272285
```Rust
273286
RIDL!{#[uuid(0xd9f6ee60, 0x58c9, 0x458b, 0x88, 0xe1, 0x2f, 0x90, 0x8f, 0xd7, 0xf8, 0x7c)]
274287
class SpDataKey;}

0 commit comments

Comments
 (0)