Static Function Declarations

Most examples and tutorials for the Apache API show modules with global handler functions declared as static. This is not currently a problem with the egcs compiler suite but it is an anchronism to declare functions as static in C++ programs and should not be necessary.

I actually use static function declarations in my C++ modules so I haven't tested using them without those declarations. This is a placeholder for specific examples and more details on internal vs. external linkage and any space/time related issues.

External Documentation

Stroustrup (3rd ed.), page 200 says:

In C and older C++ programs, the keyword static is (confusingly) used to mean "use internal linkage" (Section B.2.3). Don't use static except inside functions (Section 7.1.2) and classes (Section 10.2.4).

Stroustrup (3rd ed.), page 819 says:

The keyword static, which usually means "statically allocated," can be used to indicate that a function or an object is local to a translation unit. For example:

// file 1:
        static int glob;
// file 2:
        static int glob;
      

This program genuinely has two integers called glob. Each glob is used exclusively by functions defined in its translation unit.

The use of static to indicate "local to translation unit" is deprecated in C++. Use unnamed namespaces instead (Section 8.2.5.1).


Zachary C. Miller
Last modified: Mon Sep 20 14:21:27 CDT 1999