Govindh B
Govindh B

Reputation: 61

Use of __declspec() in GCC or G++ (Linux)

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")

Upvotes: 4

Views: 16464

Answers (1)

danglingpointer
danglingpointer

Reputation: 4920

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")))

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

dllimport/dllexport

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

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

Upvotes: 7

Related Questions