Colin Finck ha scritto:
wchar_t must not depend on the host.
Only for the target compiler or also for the host compiler?
Why, for the target of course
So in some cases, a tool might require a system wchar_t. And the size of this wchar_t depends on the host.
THEN DON'T USE WCHAR_T. The nice asexual happy-fun wchar_t makes no guarantee. It lives in a simpler world. It's not meant as a portable format. Look at Samba, for fuck's sake. Go tell them to use wchar_t for the Unicode strings in the protocol
On the other side, we always use 2-byte unsigned wchar_t's under
Windows, so
our host tools probably only need this type. But this can depend on the situation...
No. This is defending programmers that cry "mommy" and want to use wchar_t because it's what all the cool kids use. We are not the cool kids. If an on-disk format says "Unicode", it's little-endian UTF-16, that only ACCIDENTALLY and OCCASIONALLY happens to be the same as wchar_t, and we uncool kids suck it up and use an array of USHORTs (uint16_t to be nitpicky) instead. If you don't get this, you have the touch of death and every single of your contributions drives another nail in this project's coffin. I'm dead serious. Only an open source project could afford this kind of shit
What we share between both are some of the Win32 headers like
"windef.h" or
"winnt.h".
NOWAI!!! Color me wholly unsurprised
An example of this is cmlib: It heavily uses Win32 types like ULONG and UCHAR, so it has to include "winnt.h" for defining them.
Do you think Microsoft uses winnt.h for such purposes? no way. winnt.h is a mosaic of header file fragments, and internal sources include a minimal set of appropriate header fragments. When this project will stop sucking the fake tit of "using the official Microsoft headers", maybe this kind of issue will go away
As these headers only define other names for generic types, I see no
reason
for not using them in host code as well.
"Only define other names for generic types"? of course that's not half of what they do. Stop fooling yourself. I mean THINK ABOUT IT FOR ONE SECOND. If you were to write a Linux program, would you include winnt.h for some typedefs, or find an alternative solution first? For example writing code meant to be portable in a portable manner, Alex Ionescu be damned, or creating more minimal header files for standard definitions