digitalmars.D.learn - odd use of preprocessor
- Ellery Newcomer (10/10) Nov 06 2011 poking about in elfutils headers, I've come across the following idiom
- =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= (6/16) Nov 06 2011 The only thing I can think of is fully-qualified enums. The #define
- Ellery Newcomer (2/23) Nov 06 2011 nor c++, right?
- =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= (5/28) Nov 07 2011 Even C++0x requires you to use 'enum class' for this effect. I assume
- Michel Fortin (10/16) Nov 06 2011 It's strange all right. The only reason I can come with is that they
poking about in elfutils headers, I've come across the following idiom several times /* Error values. */ enum { DW_TAG_invalid = 0 #define DW_TAG_invalid DW_TAG_invalid }; anyone know if anything strange is going on here that would prevent trivial conversion to d?
Nov 06 2011
On 06-11-2011 20:43, Ellery Newcomer wrote:poking about in elfutils headers, I've come across the following idiom several times /* Error values. */ enum { DW_TAG_invalid = 0 #define DW_TAG_invalid DW_TAG_invalid }; anyone know if anything strange is going on here that would prevent trivial conversion to d?The only thing I can think of is fully-qualified enums. The #define ensures that you _don't_ have to fully qualify DW_TAG_invalid. But why they would do this (considering C doesn't have this enum feature), I don't know. - Alex
Nov 06 2011
On 11/06/2011 01:50 PM, Alex Rønne Petersen wrote:On 06-11-2011 20:43, Ellery Newcomer wrote:nor c++, right?poking about in elfutils headers, I've come across the following idiom several times /* Error values. */ enum { DW_TAG_invalid = 0 #define DW_TAG_invalid DW_TAG_invalid }; anyone know if anything strange is going on here that would prevent trivial conversion to d?The only thing I can think of is fully-qualified enums. The #define ensures that you _don't_ have to fully qualify DW_TAG_invalid. But why they would do this (considering C doesn't have this enum feature), I don't know. - Alex
Nov 06 2011
On 06-11-2011 21:36, Ellery Newcomer wrote:On 11/06/2011 01:50 PM, Alex Rønne Petersen wrote:Even C++0x requires you to use 'enum class' for this effect. I assume this is to cope with <some random compiler>'s craziness. But I have no idea, really. - AlexOn 06-11-2011 20:43, Ellery Newcomer wrote:nor c++, right?poking about in elfutils headers, I've come across the following idiom several times /* Error values. */ enum { DW_TAG_invalid = 0 #define DW_TAG_invalid DW_TAG_invalid }; anyone know if anything strange is going on here that would prevent trivial conversion to d?The only thing I can think of is fully-qualified enums. The #define ensures that you _don't_ have to fully qualify DW_TAG_invalid. But why they would do this (considering C doesn't have this enum feature), I don't know. - Alex
Nov 07 2011
On 2011-11-06 19:43:15 +0000, Ellery Newcomer <ellery-newcomer utulsa.edu> said:/* Error values. */ enum { DW_TAG_invalid = 0 #define DW_TAG_invalid DW_TAG_invalid };It's strange all right. The only reason I can come with is that they want to prevent someone else from defining DW_TAG_invalid as a preprocessor value that would shadow the enum value. Just ignore it, D has no preprocessor. :-) -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Nov 06 2011