Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8920139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:11:36+00:00 2026-06-15T06:11:36+00:00

Possible Duplicate: Unnamed/anonymous namespaces vs. static functions Is this completely redundant, or may there

  • 0

Possible Duplicate:
Unnamed/anonymous namespaces vs. static functions

Is this completely redundant, or may there be a reason to do this?

namespace {
  static void f() {
    ...
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:11:38+00:00Added an answer on June 15, 2026 at 6:11 am

    It looks redundant to me — either being declared static or being in an anonymous namespace means it has internal linkage.

    §3.5/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;

    §3.5/4:

    […] An unnamed namespace or a namespace declared directly or indirectly within an unnamed namespace has internal linkage. […] A name having namespace scope that has not
    been given internal linkage above has the same linkage as the enclosing namespace if it is the name of
    — a variable; or
    — a function; or

    So, as it is right now, it has internal linkage because it’s explicitly declared static. If it wasn’t explicitly declared static, it would have internal linkage because it’s declared inside an unnamed namespace. Same effect either way.

    Note that here I’m replying specifically about a function — there are a few obscure cases where there’s a difference when you’re dealing with the name of a type (e.g., class/struct/union), but I don’t know of any such thing that applies in the case of a function.

    As far as what internal linkage really means, that’s one of those places the standard is actually quite direct and clear. It’s probably best to quote the definitions of all three possibilities (§3.5/2):

    1. When a name has external linkage, the entity it denotes can be referred to by names from scopes of other translation units or from other scopes of the same translation unit.
    2. When a name has internal linkage, the entity it denotes can be referred to by names from other scopes in the same translation unit.
    3. When a name has no linkage, the entity it denotes cannot be referred to by names from other scopes.

    Note that the italics above match those in the standard, which is its way of saying that these sentences define what those phrases mean throughout the rest of the standard.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Unnamed/anonymous namespaces vs. static functions I came across this code namespace ABC
Possible Duplicate: Superiority of unnamed namespace over static? Why unnamed namespace is a“ superior”
Possible Duplicate: Why are unnamed namespaces used and what are their benefits? Looking at
Possible Duplicate: Create Generic method constraining T to an Enum Is there any reason
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Objective C for Windows iPhone development on Windows Is there any way
Possible Duplicate: get name of a variable or parameter I have this function. public
Possible Duplicate: Is there some ninja trick to make a variable constant after its
Possible Duplicate: Model.find(1) gives ActiveRecord error when id 1 does not exist If there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.