RFC: Make dllimport/dllexport imply default visibility

Geoffrey Keating geoffk@apple.com
Wed Jul 4 03:36:00 GMT 2007

On 03/07/2007, at 7:37 PM, Mark Mitchell wrote:

> Geoffrey Keating wrote:
>> Yes.  __attribute__((visibility)) has consistent GNU semantics, and
>> other features (eg. -fvisibility-ms-compat, __dllspec) match other
>> compilers.
> The only semantics that make sense on SymbianOS are the ones that  
> allow
> default visibility within a hidden class.

I think we're talking past each other.  What semantics exactly are  
these?  Who created them?  Where are they implemented?  Are they  
documented?  Who documented them?  Why can't they be changed?

I don't know what you mean by 'make sense'.  Clearly these semantics  
do make sense; no-one's brain has exploded yet.  You probably mean  
'compatible with the system headers' or possibly 'that I like'  or  
perhaps 'that my users like' or 'that my users understand'.

>   So, whether or not there's a
> command-line option, it's going to be on by default, and therefore is
> going to be inconsistent with a system on which GCC disallows (or
> ignores) that.

Maybe, and maybe not.  In particular, an option that changes defaults  
is one thing, but if the user overrides the default with GCC-specific  
syntax and the compiler does something different, that's another  
thing altogether.

>> I hope you don't mean that there are other system's compilers  
>> using the
>> '__attribute__((visibility))' syntax in a way that's incompatible  
>> with
>> GCC.  If there are, I think the appropriate response is a  
>> combination of
>> fixincludes and a polite e-mail asking them to stop.
> I don't know if there are, but I certainly wouldn't be surprised.  The
> GNU attribute syntax is implemented in the EDG front end and there are
> lots of EDG-based compilers.

This doesn't quite count, because EDG implements it to be compatible  
with GCC, and I'm sure if you find it isn't then they'll fix it (or  
at least acknowledge it as a bug).

> RealView 3.0.x doesn't support the visibility attribute, but it does
> support other GNU attributes.

So it can't conflict.

>   __declspec(dllexport) and
> __attribute__((visibility("default"))) are synonyms on SymbianOS.

As far as I can tell they're synonyms everywhere, although my  
understanding is subject to change through bug reports.  The question  
is about "__attribute__((visibility("hidden")))".

If you have -fvisibility-ms-compat switched on, then

struct S {
   void f() __dllspec(dllimport);

is entirely valid and does what you want to do.  So if you're just  
trying to be compatible with Visual Studio, or trying to be  
compatible with people trying to be compatible with Visual Studio,  
that's already implemented.

And likewise, for new code, the answer is to not make 'S' hidden in  
the first place, which by coincidence is also:

struct S {
   void f() __dllspec(dllimport);

or so.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2462 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20070704/d72044d9/attachment.p7s>

More information about the Gcc mailing list