|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - anonymous namespace problem
Hello to all SC/DMC users. It's fine to have a newsserver access again.
So I use this first message to come on with a problem in the
implementation of anonymous namespaces (Version 7.6B68n). This small
example will show the error. It consists of 2 separate files:
--------- A.CPP -------------
#include <iostream.h>
namespace {
int local;
}
void func();
int main()
{
local = 1;
cout<< "local=" << local << endl;
func();
cout<< "local=" << local << endl;
return 0;
}
--------- B.CPP -------------
namespace {
int local; // should not collide with other files
}
void func()
{
local = 2;
}
------- end example -------
The resulting printout is
local=1
local=2
but it should be
local=1
local=1
The problem is that the compiler adds a name called unique to the
namespace variable. This can maybe solved by adding a timestamp to this
identifier or a combination of filename and timestamp.
Heinz
Jan 09 2001
|