-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[docs]: warning for long
, culong
being OS-dependent
#25012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Docs are routinely compiled on a different OS so often don't reflect reality of CT-conditionals.
they're not |
That isn't very helpful, isn't it? I understand that C types are allowed to be implementation-defined within constraints, but that's like a warning to a warning. This PR is to fix a blatant lie when your docs were compiled on different type of OS. With it your code might possibly still be incorrect, but at least it will compile if you follow the docs 🤦. Anyway, Nim sources are rather unnuanced on the topic - they assume LLP64 for Windows and LP64 for everything else. BTW, what C standard does Nim aim for? Fixed-sizes ints have been there since C99, I believe.
Not sure I get you, why would you adapt basic types for some C library? |
it's very helpful: it tells the reader that if they want a specific behavior, they have to define it, ostensibly by using other types in their public API. The issue is that The use case for any I'm not sure what problem you're facing but I can't think of any where relying on that a particular nim type is used for any of these C types.
Nim sources are rather unnuanced (some would call them buggy), for a lot of things.
On the C side, you're maybe confusing
If nim were to become more nuanced, it would potentially have to be more creative in its |
to be clear: the problem with this statement is that it asserts that on non-windows, you get an |
Well if you want to warn, make the warnings reflect reality. The reality is these types are ABI defined. (Also, we don't generate "C code", we generate "GNU C", "MSV C", etc. avoiding most of C's problems. (You cannot even memcmp two structs in C due to their unspecified alignment gaps...)) |
I'm not confusing, I'm specifically asking about
Well, I can (the latter), as Nim
I bumped into some code that converted between |
I though about reducing the branching to just conditionally defining |
One could argue that the implementation-defined typedef is more helpful since the user of these api is not supposed to rely on these being of any specific (nim) type (or size!) and should always explicitly convert them back and forth if they happen to interact with nim types - the typedef will guide them towards the documentation instead of thinking that these are normal Nim integers. Put another way, whenever you cross the boundary between nim and C, you need to include explicit conversion code that also checks for things like the size of the type. |
Extending this line of arguments, one could say there's not much point of really providing any Nim type implementation in the type's signature ( Then we can safely use those types casting to whatever, as God commanded. |
well, that's what implementation-defined means in this context - we want to hide it as far as possible so that developers don't rely on it being anything in particular because its key property is being an re ct, |
Ok, I wrote a long and slightly too personal of a response which boils down to "thanks, sorry, out of scope"1. I fully understand the seriousness of the implications of that whole mountain of leaky abstractions built on top of C, but considering personal circumstances, I'm not the one to attempt to fix it even slightly, for the moment. I'd appreciate direct objections or GH-powered suggestions to this (initially drive-by by intention) PR. Sorry for not being receptive enough. Footnotes
|
my comment was in support of using this style, not sure gh-suggest is the right avenue for it. it's not a blocker for the PR, merely an idea to reduce maintenance for a future in which this gets fixed propery - I certainly agree that the proper fix is out of scope, this is a messy corner. |
Thanks for your hard work on this PR! Hint: mm: orc; opt: speed; options: -d:release |
Docs are routinely compiled on a different OS so often don't reflect reality of CT-conditionals. I bet there's a few of other places like this in the stdlib. (cherry picked from commit 6bdb069)
Docs are routinely compiled on a different OS so often don't reflect reality of CT-conditionals.
I bet there's a few of other places like this in the stdlib.