# Unnamed namespaces and static

If you want to make a function only visible within a compilation unit in C++ there are two ways of doing it:

1. Use an unnamed namespace:

namespace {
void internal_function();
};


2. Use static:

static void internal_function();


The advantage of the unnamed namespace is that it allows external linkage, so you can have class declarations local to the translation unit, as well as external linkage constants that can be used as template arguments.

There was an idea to deprecate static but that has now been reversed.