user220878
user220878

Reputation:

Linkage of a Static Function in a Namespace in C++

What is the linkage of a static function declared in a non-global namespace?

Example:

namespace foo {
  ...
  static void bar(int a) { }
}

Is this any different than a static method declared at the global namespace scope? Can someone point me to the place in the standard where this is laid out?

Thanks!

Upvotes: 5

Views: 3252

Answers (1)

static when used in a function at namespace level means internal linkage.

The specific quote would be from 3.5 Program Linkage, paragraph 3:

A name having namespace scope (3.3.6) has internal linkage if it is the name of

  • a variable, function or function template that is explicitly declared static; or, [...]

Upvotes: 9

Related Questions