C++ GCC(ARM)相当于_udeclspec(dllexport)
为x86构建应用程序时,以下代码可以正常工作:C++ GCC(ARM)相当于_udeclspec(dllexport),c++,gcc,arm,dllexport,visual-studio-2010,C++,Gcc,Arm,Dllexport,Visual Studio 2010,为x86构建应用程序时,以下代码可以正常工作: #if defined _WIN32 #define LIB_PRE __declspec(dllexport) #elif defined __unix__ #define LIB_PRE #else #define LIB_PRE __declspec(dllexport) #endif 但是给出了GCC(ARM)的一个错误。我发现declspec(dllexport)不能在GCC上工作。如果是,我应该为GCC(ARM)使用什么 编辑:
#if defined _WIN32
#define LIB_PRE __declspec(dllexport)
#elif defined __unix__
#define LIB_PRE
#else
#define LIB_PRE __declspec(dllexport)
#endif
但是给出了GCC(ARM)的一个错误。我发现declspec(dllexport)不能在GCC上工作。如果是,我应该为GCC(ARM)使用什么
编辑:
它在许多班级中使用。e、 g:
class CJsonValueString : public CJsonValue
{
private:
jstring value;
public:
LIB_PRE CJsonValueString(jstring value);
LIB_PRE CJsonValueString(const CJsonValueString * value);
LIB_PRE jstring ToString() const;
LIB_PRE int ToInt() const;
LIB_PRE int64 ToInt64 () const;
LIB_PRE float ToFloat () const;
LIB_PRE void GetValue(jstring & str) const;
};
基本上,你可能不需要什么特别的东西。但是,如果您愿意(如果您正在处理共享对象,即
*.so
文件),请了解更多信息和可见性
问题更多的是特定于目标操作系统,而不是特定于目标机器。(我可以想象,运行一些晦涩的Windows8/ARM系统的ARM也需要您的
\uuuuudeclspec
;相反,您的\uuuudeclspec
在Linux/x86上没有意义) 下面是我们在代码中使用的简化版本
#ifdef __cplusplus
#define EXTERNC extern "C"
#else
#define EXTERNC
#endif
#if defined(__NT__) // MS Windows
#define idaapi __stdcall
#define ida_export idaapi
#if defined(__IDP__) // modules
#define idaman EXTERNC
#else // kernel
#if defined(__X64__) || defined(__NOEXPORT__)
#define idaman EXTERNC
#else
#define idaman EXTERNC __declspec(dllexport)
#endif
#endif
#define ida_local
#elif defined(__UNIX__) // for unix
#define idaapi
#if defined(__MAC__)
#define idaman EXTERNC __attribute__((visibility("default")))
#define ida_local __attribute__((visibility("hidden")))
#else // Linux
#if __GNUC__ >= 4
#define idaman EXTERNC __attribute__ ((visibility("default")))
#define ida_local __attribute__((visibility("hidden")))
#else
#define idaman EXTERNC
#define ida_local
#endif
#endif
#endif
在Linux/OS X上,我们默认使用-fvisibility=hidden-fvisibility inlines hidden
编译所有代码,并标记要使用idaman
导出的内容,例如
idaman bool ida_export set_enum_width(enum_t id, int width);
<> P>既然你在导出C++方法,你可能会跳过