Closed smarsching closed 5 years ago
Having to use explicit namespaces everywhere is exactly what I hope to avoid. On the other hand, the commands are ugly C++ anyway. Should be a class instead of an enum with virtual methods instead of if/switch trees.
As a quick fix, I think it would be sufficient to use an enum class
instead of an enum
. The elements of an enum class
are not visible in the parent namespace and thus there would be no collision. The only downside of this fix is that enum class
is a C++ 11 feature and I do not know whether you are willing to drop support for older C++ compilers.
Another fix would be renaming the wait
element (e.g. to waitCmd
). Actually, this was my first fix, but this has the disadvantage that this also renames the string generated by the preprocessor macros, so debug or error messages would refer to waitCmd
instead of wait
, which might be misleading.
I have put the enum inside the StreamCore class. See commit 26877de. Does this help? (On Linux it compiles, even with sys/wait.h included.) The change is on branch "fix_for_macOS" at the moment. Please check it this solves the problem.
Yes, this branch fixes the problem for me. Thank you very much for your effort!
Merged into master.
There is a bug in StreamDevice 2.8.8 when compiling on macOS (10.13.6). The compiler reports the following problem when compiling
StreamCore.cc
:This problem is caused by the fact that on macOS
stdlib.h
includeswait.h
which declares thewait
function. This behavior can be avoided by passing-D_ANSI_SOURCE
to the compiler, but doing that causes problems in other places, because it also leads tostrncasecmp
(and most likely some other functions) to be skipped.A fix that worked for me is moving the enum definition into a private namespace and then only importing the symbols that do not collide, as implemented by the following patch:
A more elegant solution would be to put the whole code into a namespace, but in this case we would also have to touch all the other files, so that everything belonging to StreamDevice is in the same namespace.
If you would like a PR for the patch included above, or for the alternate solution suggested by me, please let me know.