Visual C++ namespace error

cpp.net United Kingdom
  • 14 years ago

    Hi there

    I am just getting started with Visual C++ and am having a problem trying to 'use' a namespace in my code which I hope someone can help me with. The namespace in question is included in a dll (I do not have access to the code used to create the dll). The steps I have taken so far within my C++ project are :

    1.  Added the dll to the project using Add->Existing Item and then navigating to the dll location.

    2. Opened the Object Browser and found the assembly for the new dll (which has the namespace I need listed below it) and clicked the 'Add to References in Selected Project...' button.

    3. In Solution Explorer right click on my project and select References.. and I see the new assembly listed there.

    4. Edited my .cpp file and added  a 'using namespace' command for the namespace (SBS)  in the dll/assembly as below:

    #include

    "stdafx.h"

    #include <iostream>

    #include

    <string>

    using

    namespace std;

    using

    namespace SBS;

    When I try to build the project I get the error :

    error C2871: 'SBS' : a namespace with this name does not exist

    Is there something else I need to do to get my project to recognise the 'SBS namespace ?

    Thanks in advance

    Rob

     

     

  • 14 years ago

    Hi Rob

    Use #include <cstring> instead of <string>

    Regards

    DoctorMahdi

     

     

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Beware of bugs in the above code; I have only proved it correct, not tried it.” - Donald Knuth