This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Namespace support?


"MISTY D LINVILLE" <linvilmd@daleth.grace.edu> writes:
> Hi!  I'm a new C++ student, and I'd rather not use a commercial 
> compiler at this point, since I'm poor. :)  I'm interested in 
> Cygnus-win32, but I have some questions.  First, will the compiler 
> balk if I remove the .h from all the header files? (the prof likes it 
> this way, since it's the new VC++ standard), and secondly, will the 
> line 'using namespace std;' compile cleanly, in this compiler?  I'm 
> not even entirely sure what this line is for, but it's in every 
> example in the book, and VC++5 compiles it beautifully, but VC++ 4 
> doesn't, nor does djgpp.  I find that if I leave out that line and 
> say <header.h> instead of just <header>, it compiles fine, but the 
> prof doesn't like it.  I'd appreciate any help!

Misty,

The latest GNU C++ released as part of egcs-1.1 does support namespaces,
but with a few caveats --
  
  - the "using" directive is not quite standard. It uses ARM style lookup
    instead of the new kind. The following fails for example:
      
      struct A {
        void f(int);
      };
  
      struct B : A {
        using A::f;
        void f(long);
      };
  
  - the C++ runtime library still lags behind the standard quite a bit.
    KAI and MSVC are the only two that I have access to that comes with
    standard ones, even though the one for MSVC is somewhat crippled to
    compensate for compiler limitations.

    The biggest side-effect of the lack of standard runtime library for
    GNU C++ is that all the symbols in dumped into global namespace, not
    in std. However, ``using namespace std'' works just fine.

    I have just a few #ifdefs in my code when egcs C++ became featureful
    enough to build it (we normally use EDG based compilers on both Unix
    and win32), and I'm hoping to get rid of those pretty soon. And,
    no, MSVC 5/6 can't even grok most of this code thanks to lousy
    template handling.

EGCS-1.1 is the first release with namespace support, so quite a few rough
edges remain. With the new standard C++ library in the works, and egcs
improving namespace support, we can look forward to a much better compiler
in the future.

Your prof is correct that using <header> is definitely better style than
using the corresponding .h file due to proper scoping. However, your
prof is quite incorrect that VC++ *defines* any "standard"; in fact, 
MSVC is not even that good at *following* the standard ;-)

Note that you can't just remove the .h, since the C-style headers are
wrapped with a "c" in front, eg., <stdlib.h> --> <cstdlib>.

I suggest you try it out and see for yourself.  I also suggest that you
take a quick look (and ask your prof to do the same!) at egcs-1.1. You
can get more info at <URL:http://egcs.cygnus.com/>.

Regards,
Mumit

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]