I write a library, inside it looks like this:
User program> library> library module
(gcc -shared -fPIC -o liblib.so lib.c module.c)

The module implements certain functions that are used in the library, but I do not want these functions to be used in the user program, they must be static. How to make them static?
If the library will have a header:

static void function(); 

And in the implementation module:

 void function() {...} 

That will not work. Due to the static header, the header itself loses contact with the body in the module. If you specify static in the module, the library will not see it. Without static in the library, the function will not be static.

  • Do not describe them in h-files, but only in implementation files — as extern void function(); - Only the names must be given such strange :) so that there is no accidental collision. Then external modules about them will not be suspected ... - Harry
  • Gcc has visibility - gcc.gnu.org/wiki/Visibility - Abyx
  • If you understand what static means for functions, then you understand the uselessness of such use in the library. Option - define the function body in the header as static inline along with the implementation. - 0andriy

0