Q_DECL_EXPORT关键字含义 [英] Q_DECL_EXPORT keyword meaning

查看:3543
本文介绍了Q_DECL_EXPORT关键字含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Q_DECL_EXPORT int main(int argc,char ** argv)

int main(...)之前的 Q_DECL_EXPORT 意味着?

推荐答案

摘录自 QT docs


根据您的目标平台,Qt提供了特殊的宏,
包含必要的定义:

Depending on your target platform, Qt provides special macros that contain the necessary definitions:


  • Q_DECL_EXPORT必须添加到编译共享库时使用的符号声明。

  • Q_DECL_IMPORT必须添加到编译使用共享库的客户端时使用的符号声明。

我没有检查QT代码,但很可能这个宏将执行以下操作:

I haven't check the QT code, but most likely this macro will do following:

#ifdef _WIN32 || _WIN64
    #define Q_DECL_EXPORT __declspec(dllexport)
    #define Q_DECL_IMPORT __declspec(dllimport)
#else
    #define Q_DECL_EXPORT
    #define Q_DECL_IMPORT
#endif

__ declspec(dllimport) and __ declspec(dllexport)告诉链接器分别从或向DLL导入和导出符号。

__declspec(dllimport) and __declspec(dllexport) tells the linker to import and export (respectively) a symbol from or to a DLL. This is Windows specific.

在特定情况下,此宏可能会被删除,因为 main()不是图书馆的一部分。

In your particular case this macro probably could be removed, since main() most likely is not part of a library.

这篇关于Q_DECL_EXPORT关键字含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆