Hello,
I'm playing with clang++ and try to compile some C++ project but I have a problem with symbol visibility (that I don't have with GCC).
First, I'm use to compile all my projects using the -fvisibility=hidden to make sure I'm only exporting public symbols.
I'm including a system header (<CoreAudio/CoreAudioTypes.h>) which define structs inside an extern "C" block.
extern "C" {
struct AudioTimeStamp {
// misc fields
};
typedef struct AudioTimeStamp AudioTimeStamp;
}
As I'm using -fvisibility=hidden, the structs are marked as private_extern (maybe they shouldn't as we are in an extern "C" block).
Now, in my header, I declare a function that take a pointer on AudioTimeStamp:
extern "C" __attribute__((visibility("default"))) void Foo(AudioTimeStamp *ts);
As the argument is of a type marked 'private extern', clang++ ignores the visibility attribute of the function and marks it as private_extern which result in a non-exported symbol.
Here is a reduced test case:
======================= Foo.cpp ======================
extern "C" {
struct AudioTimeStamp { int field; };
typedef struct AudioTimeStamp AudioTimeStamp;
}
extern "C" __attribute__((visibility("default"))) void Foo(AudioTimeStamp *timeStamp);
void Foo(AudioTimeStamp *timeStamp) {}