更新时间:2023-09-19 15:24:04
原来我最初的尝试大部分都在那里.以下作品:
It turns out my original attempt was mostly there. The following works:
extern "C" void Af(void);
void (*Af_fp)(void) = &Af;
对于那些想要一个独立的预处理器宏来封装它的人:
For those that want a self-contained preprocessor macro to encapsulate this:
#if defined(_WIN32)
# if defined(_WIN64)
# define FORCE_UNDEFINED_SYMBOL(x) __pragma(comment (linker, "/export:" #x))
# else
# define FORCE_UNDEFINED_SYMBOL(x) __pragma(comment (linker, "/export:_" #x))
# endif
#else
# define FORCE_UNDEFINED_SYMBOL(x) extern "C" void x(void); void (*__ ## x ## _fp)(void)=&x;
#endif
这样用的:
FORCE_UNDEFINED_SYMBOL(Af)