comp.lang.ada
 help / color / mirror / Atom feed
* C++ diaries...
@ 2019-06-06 16:32 Olivier Henley
  2019-06-06 16:54 ` Olivier Henley
  0 siblings, 1 reply; 9+ messages in thread
From: Olivier Henley @ 2019-06-06 16:32 UTC (permalink / raw)


I have to share to stay healthy ... I probably came across this one already but my brain just shuts off some times over this kind of well ... absurdity ... for the lack of a better word. :)

In C++:

namespace Whatever {
    enum SocketType {Stream, DGram, Raw};
    enum ProtocolType {IP, IPV6, Raw};
}

Will not compile and give you this: 

Error C2365	'Whatever::ProtocolType::Raw': redefinition; previous definition was 'enumerator'. 

Now a small search on SO gives:

"You cannot have equal names in old c-style enums. If you have C++11 - you can use enum class, static constants in classes, different namespaces, or you can simply use different names."

🤦

Looks like I have to use the new, third or fourth or fifth or ..., handle "from the water tap to not get sulfuric acid"*.

Olivier

p.s: I was so amazed, I triple checked, it works properly in Ada.

*(copyright by Dmitry Kazakov and reproduced with no permission)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-06-07 23:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-06 16:32 C++ diaries Olivier Henley
2019-06-06 16:54 ` Olivier Henley
2019-06-07  7:32   ` Maciej Sobczak
2019-06-07 17:55     ` Olivier Henley
2019-06-07 18:22       ` Keith Thompson
2019-06-07 23:04         ` Olivier Henley
2019-06-07 23:09         ` Keith Thompson
2019-06-07 18:29       ` Lucretia
2019-06-07 23:27         ` Olivier Henley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox