Character Visibility on Windows

I program a lot on linux and I use the visibility attribute to determine if a character is visible or hidden in a shared object. Just to make things clearer: if the symbol is visible, it will be accessible from the outside (someone is connected to a shared object), if it is hidden, it should only be used internally.

In windows, this works a little differently, it works with export (the symbol is defined here in the shared object and will be accessible by someone related to it) and import (here I am connecting with the shared object and the symbol is exported there). But I could not find a way to tell the compiler not to export the character, because it should be used only here, that is, if someone contacts him, a linker error is expected.

My question is, can I define the character as "hidden" (as in linux gcc) and how. Also, all this visibility in the Windows theme is a bit fuzzy for me, and I was looking for some additional reading links to better understand how everything works.

+2
c ++ windows visual-c ++ mingw
source share
1 answer

David Rodriguez is right, in an MSVC environment, a programmer usually explicitly exports function / class characters using the __ declspec (dllexport) modifier defined by MSVC. Characters that are not explicitly exported should not be displayed in the symbol table for the compiled DLL (you can use dumpbin , one of the Visual Studio command line utility commands to check using the / EXPORT option). Consent to use dllimport when importing this symbol, although I consider this to be optional. As this usually happens, the header files that define the open DLL interface will have a macro that expands to __declspec (dllimport) by default, but to expand this library it expands to __declspec (dllexport).

Please note that the use of GCC and MSVC for dllexport may be different; perhaps GCC does not "respect" dllexport in the sense of hiding unexported characters? First I will try to compile with MSVC and test these results with dumpbin before trying to use GCC. If you don't have Visual Studio, you can still get the MSVC compiler, either by downloading VS Express, or (less well-known) by downloading some common redistributable .NET that ship with the MSVC command line (both of these are free and legal). VS Express may be the best choice here so you can get dumpbin.

+5
source share

All Articles