% cat foo.cxx
// foo.cxx
#include <snack.h>
// End of file
% g++ -I .../path-to-snack-headers -c foo.cxx
In file included from snack.h:33,
from foo.cxx:2:
jkSound.h:307: error: declaration of 'int (* SnackFileFormat::getHeaderProc)(Sound*, Tcl_Interp*, Tcl_Channel_*, Tcl_Obj*, char*)'
jkSound.h:275: error: changes meaning of 'getHeaderProc' from 'typedef int (getHeaderProc)(struct Sound*, struct Tcl_Interp*, struct Tcl_Channel_*, struct Tcl_Obj*, char*)'
...
In C this compiles fine:
% g++ -xc -I $SIXXBASE/include/si++ -c foo.cxx
Obviously the snack structs are not c++ compatible although the headers
have some #ifdef __cplusplus markers in them.
I've tried some combinations, but short from duiplicating the relevant
structs in C++ using different namings I'm running out of ideas...
Some tips anyone?
What I'm trying to do is to add some customized filters to massage the
sound as it is played...
R'
> I'm trying to extend the Snack library version 2.2.10 by c++ but am
> running into compilation errors like the following:
[...]
May be you should do
// foo.cxx
extern "C" {
#include <snack.h>
}
// End of file
instead?
Doesn't help. The problem is that in C++ you can't have structs
(==classes) with members having the same name as a typedef:
typedef int foo;
struct x {
foo foo;
};
is not valid in C++ (while it is in C), and the Snack headers use this
idiom a lot.
% g++ -c foo.cxx
foo.cxx:4: error: declaration of 'foo x::foo'
foo.cxx:2: error: changes meaning of 'foo' from 'typedef int foo'
If you tell the compiler this is really "C" it works:
% g++ -xc -c foo.cxx
extern "C" only changes the name mangling, not the syntax rules...
R'