rust-tutorials / triangle-from-scratch

Drawing a triangle with no other crate dependencies.
https://rust-tutorials.github.io/triangle-from-scratch/
40 stars 6 forks source link

Reading a C constant definition? #20

Closed MaulingMonkey closed 3 years ago

MaulingMonkey commented 3 years ago

https://rust-tutorials.github.io/triangle-from-scratch/opening_a_window/win32.html#creating-the-window introduces constants derived from C #defines. Earlier asides such as Reading a C struct declaration seem to imply the audience isn't assumed to know C - so it might be worth briefly noting what these look like in the original C headers (e.g. #define WS_OVERLAPPED ... / enum { ... }) and how the exact type these match to in Rust can be somewhat ambiguous / down to the author's own personal guesswork.

Lokathor commented 3 years ago

Good point. I had to deal with this early this morning when talking about CS_OWNDC.

For many of the initial value we can see them in msdn without looking at headers, but I'll try to find the first spot where we're forced to look at headers and explain how #define works.