Ronald Oussoren <[email protected]> added the comment:
Switches from #define's to an enum would allow explictly deprecating the old
name (at least with clang and probably with GCC as well):
clang -c -Wall t.c
t.c:12:10: warning: 'READONLY' is deprecated: use PY_READONLY
[-Wdeprecated-declarations]
int i = READONLY;
^
t.c:7:26: note: 'READONLY' has been explicitly marked deprecated here
READONLY __attribute__((deprecated("use PY_READONLY"))) = PY_READONLY
^
1 warning generated.
For this source code:
#include <stdio.h>
enum {
PY_READWRITE = 0,
PY_READONLY = 1,
READONLY __attribute__((deprecated("use PY_READONLY"))) = PY_READONLY
};
int main(void)
{
int i = READONLY;
printf("%d\n", i);
return 0;
}
I'm not sure if it worthwhile switch to an enum here, the CPython source code
isn't consistent in using enums for constants like this.
----------
nosy: +ronaldoussoren
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue36347>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com