Thread: Namespace name expected

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    7

    Namespace name expected

    Just wondering if you guys can help with this:

    #include <iostream>
    #include <cstring>
    #include <stdlib>

    using namespace std;

    ....


    This is what I have in my header. When I try to compile, the "Namespace name expected" error pops up. Eventhough I clearly have it in there. Oh yes, this code compiles correctly on the Unix systems at school but does not compile on my home puter which is running Borlandv5.02 and Windows. Any ideas anybody.

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    244
    Does Borland 5.02 support that or is it pre-1998? I've never used Borland, and thats the only reason I can think of as to why that wouldn't work..

  3. #3
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    is that the free command line version? if so did you set the enviornment variables like the readme.txt file said?

  4. #4
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    If it is standard C++ compliant <stdlib> should be <cstdlib> so:

    Code:
    #include <iostream>
    #include <cstring>
    #include <cstdlib>
    
    using namespace std;
    Try this.

    Mr. C.

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    7
    thanks alot guys for the help. I ran the code under MS Visual C++ and it works perfectly. I didn't try to solve the problem in Borland instead just went straight to Visual C++. Mr C i did try using the cstdlib header as well and it still didn't work.

  6. #6
    Registered User
    Join Date
    Jul 2007
    Posts
    2
    Using Borland C++ 5.02, (the GUI version), and having the same issue.

    Very frustrating.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Welcome to the boards. If you haven't already done so then please take some time to familiarise yourself with the faq:
    http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

    Make sure you have a look at the the posting guidelines:
    http://cboard.cprogramming.com/annou...ouncementid=51
    Following the rules will ensure you get a prompt answer to your question.

    Remember, too, that the board has a search facility, a link is at the top of your screen:
    http://cboard.cprogramming.com/search.php
    It will often get you a quicker answer to your questions than waiting for a response to one you have posted.


    If you have any questions about this you may ask or you can contact one of our forum leaders:

    http://cboard.cprogramming.com/showgroups.php

    --------------------------------------------

    In this case, it looks like you were able to search for a similar problem, but it would be better to start a new thread and link to the one you find rather than bumping the old thread.

    Borland 5.02 appears to be a very old compiler that probably doesn't support modern, standard C++ (and in this case namespaces). Consider using a different compiler. There are several free IDEs available that come with good modern compilers (e.g. VC++ Express, Dev-C++, Code::Blocks).

  8. #8
    Registered User
    Join Date
    Jul 2007
    Posts
    2
    I just thought I'd respond to it as I've recently joined a software compay with a huge project that will likely never been updated to run properly with other compilers, (it's pretty dodgy), but figured there might be others in a similar boat.

    Incidentally, I found some information with regards to it:

    http://tisue.net/cs311/fall-00/notes/borland-notes.html

    It appears you can just comment out the 'using namespace std;' line.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BAH! expected `;' before 'else'
    By Chef in forum C++ Programming
    Replies: 19
    Last Post: 10-03-2008, 01:37 PM
  2. expected constructor, destructor, or type conversion before '('
    By cosmiccomputing in forum C Programming
    Replies: 5
    Last Post: 06-16-2008, 11:03 PM
  3. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 05:59 PM
  4. namespace std - After searching the the boards
    By jrahhali in forum C++ Programming
    Replies: 11
    Last Post: 08-26-2004, 04:51 AM
  5. need ; before using namespace std
    By wwfarch in forum C++ Programming
    Replies: 7
    Last Post: 05-11-2004, 10:42 PM