1

I am not sure whether having a struct fully implemented in the header file will make any difference on its need of __attribute__(( visibility("default"))) when being used as part of a shared library.

2 Answers 2

1

You shouldn't need to set visibility to default for fully inline class. Actually adding it would be undesirable as it would force class's symbols to be exported from all shared modules which include this header which would increase size of your binaries and slower startup.

Sign up to request clarification or add additional context in comments.

Comments

0

If you're compiling with

-fvisibility=hidden

All the exported functions and variables set to visibility default and so usable by the user of your shared library will appear when executing :

nm -C -D <library>.so

Then you can see the differences when you set it to default and when you don't.

2 Comments

This doesn't quite answer the question. The question is whether it makes any differences for structs with all of its implementation made in the header file. The argument I was given is that the "header file is shipped anyway along with the library, so no need to use visibility default on those structs" ...
Visibility is just to set or not the symbol in the shared library so that it can be use after, if there is no need to set it to default then there is no change to set it or not

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.