[matroska-devel] Re: Namespace pb

Steve Lhomme steve.lhomme at free.fr
Tue Apr 8 15:13:08 CEST 2003


En réponse à Cyrius <suiryc at yahoo.com>:

> Well the problem doesn't seem as simple as that.
> First of all it is due to the fact that Avery
> typedefed (u/s)int8/16/32/64, and that libebml also
> typedefed (s)int8/16/32/64.
> 
> VirtualDub doesn't use a namespace for that (yet ? -
> Avery uses namespaces in parts that have been added in
> version 1.5.0). Moreover VirtualDub uses precompiled
> headers. So the .cpp file has to #include "stdafx.h"
> first, which then include the file containing the
> typedefs.
> Then I can #include my .h file that #include
> libmatroska/libebml files. This lead to those errors :
> Compiling...
> MatroskaOutputFile.cpp
> .\mod\matroska\libebml\src\api/c/libebml_t.h(79) :
> error C2371: 'int32' : redefinition; different basic
> types
>         ..\h\vd2/system/vdtypes.h(34) : see
> declaration of 'int32'
> .\mod\matroska\libebml\src\api/c/libebml_t.h(80) :
> error C2371: 'int16' : redefinition; different basic
> types
>         ..\h\vd2/system/vdtypes.h(35) : see
> declaration of 'int16'
> ...
> 
> (vdtypes.h is the VirtualDub file where are the
> typedefs ;))

OK. Now I see what the problem is. As the compiler says, you already define some
types that are already defined...

Now the libraries are supposed to be usable in any application and so they
should fit in the code without much problem. That's what namespaces are for. I'm
a bit surprised that when you put START/END_LIBEBML_NAMESPACE around the code it
still produces the same. Your compiler might not be able to handle namespaces
properly then (which I don't think is the case). Maybe you didn't include the
file that specify what is in the namespace (ie EbmlConfig.h) ?

Also this should be done but it's not enough. Because there are some ancient
compilers like GCC 2.95 that don't understand standard C++ (ie namespaces). And
if you use libebml/libmatroska with other C++ code that already defined uint8
you'll end up with the same error as yours... So there should be in the code
something like this :

#if (!EBML_CLASSIC_TYPES_DEFINED)
...define them as it is now
#endif

There won't be any duplicate anymore... But there is another problem : the
library has to be compiled with these same types as you use in your own code !
Hopefully this is the case but you never know. And I don't see any way to
enforce that :( (unless we have a "port.h" file for each platform)
http://www.matroska.org



More information about the Matroska-devel mailing list