This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
namespaces
- To: egcs at cygnus dot com
- Subject: namespaces
- From: Andrew Veliath <veliaa at frontiernet dot net>
- Date: Sat, 29 Nov 1997 07:51:54 -0500
Hi,
I'm a bit of a newbie here and with regards to egcs, so please bear
with me, I may have missed something.
I'm really interested in having ANSI C++ namespace support, so I've
been toying around with trying to fix the old broken implementation
which was commented out (also took out the temporary compatibility std
namespace). I'm just looking for something that I can use on a
project that I want to rewrite in ANSI/ISO C++...
With some changes I made yesterday to egcs I can now compile the
following useless code (and it says "Hi", and it won't compile if not
given the correct scoping). Putting a namespace std { } in iostream
works (I made an iostream file), but it won't link since I didn't
compile the library with that, since the names get mangled in
namespaces.
There are a few things I am not exactly sure how to do, since I'm not
readily familiar with gcc internals. For one, I have not been able
yet to get data declarations in the namespaces to generate labled data
for some reason (I'm still trying though...:( ).
I'm going to try and implement "using" declarations and directives
soon, as well as namespace aliases, though I need to digest a bit
first.
#include <iostream.h>
namespace A {
typedef char byte;
namespace B {
typedef char byte2;
void f();
}
}
namespace {
void secret_code()
{
}
}
namespace A {
namespace B {
void f()
{
cout << "Hi" << endl;
return 0;
}
}
}
int main(int, char *[])
{
A::B::f();
A::byte d = 0;
A::B::byte2 e = 1;
return 0;
}
--
Regards,
Andrew Veliath
veliaa@frontiernet.net, veliaa@rpi.edu