TOC   Previous   Next

Controlling Symbol Visibility (cont)

Methods of preventing symbols being exported include:

The static keyword

Declaring a function or variable as static makes symbol private to a source code module.

The hidden attribute

__attribute__ ((visibility("hidden")))
func(void) {
    /* Code */

Limits visibility of symbol to all of the source code modules that compose a library.

static and hidden also have a converse effect: if a symbol is declared using one of these attributes, then symbol references within that scope are bound to that definition (cf. the -Bsymbolic linker option).

(C) 2006, Michael Kerrisk