在 GCC 或 G++ (Linux) 中使用 __declspec() [英] Use of __declspec() in GCC or G++ (Linux)

查看:64
本文介绍了在 GCC 或 G++ (Linux) 中使用 __declspec()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

__declspec() 在 GCC 编译器中有什么用?从一些研究中我发现它是一个 Microsoft 特定的扩展,用于访问共享的 .dll 库.那么它在 Linux(或像 mqx 这样的 Rots)中有什么用?这是我找到的一段示例代码,它是用 GCC 编译的.

What is the use of __declspec() in GCC compilers? From some research i found that it is a Microsoft specific extension to access shared .dll libraries. So what is it's use in Linux(or Rots like mqx)? This is a piece of sample code that i found which is to be compiled with GCC.

__declspec(section "configROM")

推荐答案

我想象的 ARM 运行一些晦涩的 WindowsX/ARM 系统也需要您的 <代码>__declspec;相反,您的 __declspec 在 Linux/x86 上没有意义.

What I would imagine that an ARM running some obscure WindowsX/ARM system would also need your __declspec; conversely, your __declspec has no sense on Linux/x86.

AFAIK,

__attribute__((visibility("default")))

据我所知,Linux 中没有与 __declspec(dllimport) 等效的东西.

And there is no equivalent of __declspec(dllimport) in linux to my knowledge.

在 cygwin、mingw 和 arm-pe 目标上,__declspec(dllimport) 是被认为是 __attribute__ ((dllimport)) 的同义词与其他 Microsoft Windows 编译器兼容.

On cygwin, mingw and arm-pe targets, __declspec(dllimport) is recognized as a synonym for __attribute__ ((dllimport)) for compatibility with other Microsoft Windows compilers.

看看 GCC 的这种可见性支持,https://gcc.gnu.org/wiki/可见性

Have a look at this visibility support from GCC, https://gcc.gnu.org/wiki/Visibility

这篇关于在 GCC 或 G++ (Linux) 中使用 __declspec()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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