日期:2014-05-16 浏览次数:20824 次
#include"stdio.h" void foo_v1(int f) { printf("foo_v1\n"); } __asm__(".symver foo_v1,foo@@VERSION_1.1"); class Clock { public:void SetTime(int NewH, int NewM, int NewS); }; void Clock::SetTime(int H, int M, int S) { int Hour = H; int Minute = M; int Second = S; printf("%d %d %d", Hour, Minute, Second); } __asm__(".symver SetTime ,SetTime@@VERSION_1.1");
//这是上边说的1.ver VERSION_1.1{ global: foo; Clock::*; };
gcc -shared -fPIC -o libfoo.so.1.1 -Wl,--soname='libfoo.so.1' -Wl,--version-script=1.ver foo.c
#include <stdio.h> class Clock; void foo(int); int main() { Clock myClock; foo(100); myclock.SetTime(10, 12, 14); return 0; }
main.cpp: In function `int main()': main.cpp:6: error: aggregate `Clock myClock' has incomplete type and cannot be defined