User forums > General (but related to Code::Blocks)

static library [SOLVED]

<< < (5/5)

Michael:

--- Quote from: sspecter on February 27, 2006, 08:48:44 pm ---Do static libraries accept namespaces?

--- End quote ---

Hello,

I have slightly modified the projects poseted by MortenMacFly to include the namespace tools. Moreover, I have remarked that there were several declarations using namespace std;. Not all are necessary.

To make it work with the namespace tools, you have to wrap not only ssptools.h, but also ssptools.cpp with:


--- Quote ---namespace tools{
...
};

--- End quote ---

Then you can use using namespace tools; in the main.cpp.


--- Code: ---#include <iostream>
#include "ssptools.h"

using namespace tools;

int main()
{
    showMessage("Hello world!\n");
    Point3D p(1,2,3);

    return 0;
}

--- End code ---

If you forget to wrap the ssptools.cpp, then it will not works, because in the library there are not the "good" methods. Therefore, you were getting undefined errors.

Also the using namespace std; in the main.cpp and ssptools.cpp are not necessary.

Best wishes,
Michael

Navigation

[0] Message Index

[*] Previous page

Go to full version