• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Anonymous namespace clashes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Anonymous namespace clashes


  • Subject: Re: Anonymous namespace clashes
  • From: Howard Hinnant <email@hidden>
  • Date: Mon, 29 Jan 2007 16:09:13 -0500

On Jan 26, 2007, at 4:39 AM, Paul Walmsley wrote:

I've just experienced a problem with anonymous namespaces. I have two source files, each with a couple of private functions and variables in an anonymous namespace. Some of these happen to have the same name. I get a 'multiply-defined symbol' error on linking. Surely - if my understanding is correct - this shouldn't happen since anonymous namespaces are local to the translation unit?

I'm trying to replicate this symptom and so far have not been able to. In one file I have:


#include <iostream>

void foo();

namespace
{
   int x = 1;
    void bar(int& y)
    {
        std::cout << y << '\n';
    }
}

int main()
{
    bar(x);
    foo();
}

In another file I have:

#include <iostream>

namespace
{
    int x = 2;
    void bar(int& y)
    {
        std::cout << y << '\n';
    }
}

void foo()
{
    bar(x);
}

This program compiles and prints out:

1
2

(as expected).

Can you perhaps reduce your problem to a small test case and either post it here or file a bug?

Thanks,
Howard

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Anonymous namespace clashes
      • From: Paul Walmsley <email@hidden>
References: 
 >Anonymous namespace clashes (From: Paul Walmsley <email@hidden>)

  • Prev by Date: Re: Turning off 'deleting 'VOID*' is undefined' error
  • Next by Date: Re: Xcode debugger not stopping on breakpoints
  • Previous by thread: Anonymous namespace clashes
  • Next by thread: Re: Anonymous namespace clashes
  • Index(es):
    • Date
    • Thread