简体   繁体   中英

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!

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, [...]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM