This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ronaldoussoren
Recipients josh.r, matrixise, ronaldoussoren, serhiy.storchaka
Date 2019-03-24.13:03:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
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.
History
Date User Action Args
2019-03-24 13:03:09ronaldoussorensetrecipients: + ronaldoussoren, serhiy.storchaka, matrixise, josh.r
2019-03-24 13:03:09ronaldoussorensetmessageid: <[email protected]>
2019-03-24 13:03:09ronaldoussorenlinkissue36347 messages
2019-03-24 13:03:09ronaldoussorencreate