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 6859773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:19:30+00:00 2026-05-27T02:19:30+00:00

Can I assume an object declared in unnamed namespace to be equivalent to as

  • 0

Can I assume an object declared in unnamed namespace to be equivalent to as if were static?

namespace { int x; };//  #1

static int x; // #2

FWIK, In both cases, x will have static storage duration and internal linkage.
So does all the rules of an object declared as static applies to an object in unnamed namespace?

For example:

  • What will be the order of construction and destruction? will it be same?
  • Can I use extern keyword with x in unnamed namespace?
  • 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-05-27T02:19:30+00:00Added an answer on May 27, 2026 at 2:19 am

    Most of your questions are answered here. For the rest:

    What will be the order of construction and destruction? will it be same?

    The order is unchanged from regular globals. So it isn’t the same as static.

    That being said, I strongly urge you to write code that does not care about the order. The less you rely on the specific order of initialization for any globals, the better.

    Can I use extern keyword with x in unnamed namespace?

    No. In order to extern something, you have to be able to type its name. And the magic of the unnamed namespace is that you can’t type its name. The name is assigned by the compiler. You don’t know it. So if you attempt to extern it, you will instead be externing something else.

    If you put an unnamed namespace in a header, every translation unit that includes it will get a different version of the variable. They’ll all be extern, but they’ll be talking about a different external variable.

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

Sidebar

Related Questions

Consider these 2 pieces of code (you can assume execeptionObj is of type Object
I have to parse a String that can assume hex values or other non-hex
First, I can assume that all urls that end with jpeg, jpg, bmp, png
I can only assume this is a bug. The first assert passes while the
From the disassembly code below can I assume that the location 43E010 is a
assume mylist can contain the values video, audio, visual or all three. I want
Before suggesting bin packing algorithms, they assume you can re-order the elements and arrange
I assume that MAMP environment variables can be set in ~/.bash_profile, but it seems
How can I convert the following array: (Assume I don't know how many depth
Let's assume that our system can perform actions, and that an action requires some

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.