Skip to content

Instantly share code, notes, and snippets.

@torarnv
Created September 17, 2010 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torarnv/584533 to your computer and use it in GitHub Desktop.
Save torarnv/584533 to your computer and use it in GitHub Desktop.
#include "foo.h"
template<Type type>
void TemplateClass<type>::exportedMemberFunction()
{
}
template void TemplateClass<Foo>::exportedMemberFunction();
#ifndef EXPORT
#define EXPORT __attribute__((visibility("default")))
#endif
enum Type {
Foo,
};
template<Type type>
class TemplateClass
{
public:
inline TemplateClass() { };
EXPORT virtual void exportedMemberFunction();
};
#define EXPORT
#include "foo.h"
int main(int, char**)
{
TemplateClass<Foo> foo;
return 0;
}
all: compile
clean:
rm -f *.o *.dylib *.app
compile: lib app
lib: clang-lib gcc-lib
clang: clang-lib clang-app
clang-lib:
clang++ -c foo.cpp -o foo.clang.o -fvisibility=hidden -fvisibility-inlines-hidden
clang++ -dynamiclib foo.clang.o -o libfoo.clang.dylib
gcc: gcc-lib gcc-app
gcc-lib:
g++ -c foo.cpp -o foo.gcc.o -fvisibility=hidden -fvisibility-inlines-hidden
g++ -dynamiclib foo.gcc.o -o libfoo.gcc.dylib
app: clang-app gcc-app
gcc-app: gcc-lib
g++ -c main.cpp -o main.gcc.o
g++ main.gcc.o -lfoo.gcc -L. -o main.gcc.app
clang-app: clang-lib
clang++ -c main.cpp -o main.clang.o
clang++ main.clang.o -lfoo.clang -L. -o main.clang.app
nm: lib
nm *.o | c++filt
nm *.dylib | c++filt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment