mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-133256: Add _Py_NONSTRING macro (#133257)
Fix GCC 15 compiler warnings such as: Modules/fcntlmodule.c:27:36: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (9 chars into 8 available) [-Wunterminated-string-initialization] static const char guard[GUARDSZ] = "\x00\xfa\x69\xc4\x67\xa3\x6c\x58";
This commit is contained in:
parent
ad2f0884b1
commit
e26bafd107
3 changed files with 17 additions and 2 deletions
|
@ -685,4 +685,19 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
// _Py_NONSTRING: The nonstring variable attribute specifies that an object or
|
||||
// member declaration with type array of char, signed char, or unsigned char,
|
||||
// or pointer to such a type is intended to store character arrays that do not
|
||||
// necessarily contain a terminating NUL.
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// char name [8] _Py_NONSTRING;
|
||||
#if _Py__has_attribute(nonstring)
|
||||
# define _Py_NONSTRING __attribute__((nonstring))
|
||||
#else
|
||||
# define _Py_NONSTRING
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* Py_PYPORT_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue