[vlc-devel] [PATCH 0/3] Respect C++ ODR (first patches)
Rémi Denis-Courmont
remi at remlab.net
Sun Apr 22 18:28:48 CEST 2018
Le dimanche 22 avril 2018, 18:03:35 EEST Romain Vimont a écrit :
> In C++, there cannot be more than one definition of a single type in the
> entire program:
> <http://en.cppreference.com/w/cpp/language/definition#One_Definition_Rule>
>
> This has been reported by #17078 and #18033.
>
> To fix the issue:
> 1. In C++ code, declare *_sys_t types in a separate namespace, either
> unnamed if it's used only in one translation unit, or named otherwise.
> 2. Remove the *_sys_t typedefs in include/vlc_common.h.
> 3. Declare *_sys_t typedefs locally for C modules.
> 4. Declare references to private data as "void *" instead of "*_sys_t *".
> 5. Adapt code that now dereferences "void *" or relied on the *_sys_t
> forward declarations.
This might fix the compilation, but as long as the same typename is defined
multiple times, the debugging will remain broken.
So I don't think this is sufficient.
Also, as far as aliasing problems are concerned, there is another potential
separate problem. I am not sure if treating objects alternatively as
vlc_object_t and as ${MODULE_TYPE}_t is valid by C++ either. In fact, I am not
even sure if it is valid in C.
--
Rémi Denis-Courmont
More information about the vlc-devel
mailing list