Uh oh!
There was an error while loading. Please reload this page.
gh-115304: Add doc for initialize PyMutex as global variables - #115305
Conversation
| // | ||
| // Typical initialization: | ||
| // PyMutex m = (PyMutex){0}; | ||
| // PyMutex m = {0}; |
There was a problem hiding this comment.
I don't think we should make this change. The comment is for variables that need explicit initialization, such as local variables and fields in heap allocated structures. Static variables are implicitly initialized to zero in C.
There was a problem hiding this comment.
Maybe instead we can add an additional example of statically initializing the PyMutex?
There was a problem hiding this comment.
Thanks for the review! For local variables, should we remove the cast (PyMutex)? Seems it is needless in modern C.
There was a problem hiding this comment.
Most commonly, we are initializing fields in a struct like:
self->mutex= (PyMutex){0};You can't write:
self->mutex= {0}; // INVALID!Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Sam Gross <colesbury@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.