Reputation: 1001
I want to take advantage of GCC's visibility attribute.
To such end, in my executable, I have a function I wish to be visible to any plugins, so they can use it to register themselves. I therefore use __attribute__((visibility("default")))
on it and -fvisibility=hidden
as an option on the command line.
This article seems to imply that attributes can only be used on declarations.
Is it possible to have the implementation of a function in a separate .cpp file and apply the attribute to only the declaration?
Upvotes: 3
Views: 1121
Reputation: 1
Yes. It is often done that way, the __attribute__
appears only at the declaration.
Upvotes: 4