From: Olivier Henley <olivier.henley@gmail.com>
Subject: C++ diaries...
Date: Thu, 6 Jun 2019 09:32:40 -0700 (PDT)
Date: 2019-06-06T09:32:40-07:00 [thread overview]
Message-ID: <ce1f4090-bdda-4a95-9d6e-c75bd497c3b0@googlegroups.com> (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)
next reply other threads:[~2019-06-06 16:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-06 16:32 Olivier Henley [this message]
2019-06-06 16:54 ` C++ diaries 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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox