Start New Discussion within our Software Development Community

Sorry about my primitive questions but I cannot find a good summary about this basic topic.

So I would like to write my own libraries: mylib.h and mylib.cpp.

I need to include some standard libraries.
But I dont want to overload them, what is the solution?
I have to use #ifdef ?
If yes, than how can I know what string goes after #ifdef for a particular library for example math.h?
I tried __MATH__, __MATH_H__, _H_MATH_ and so on, because i have seen these on the net, but I dont know which is the correct one. I tried to test them but do not work.

My other question is that how can I use my libraries if I want to insert it only in my project directory. I use MinGW g++ under XP.

>I need to include some standard libraries.
>But I dont want to overload them, what is the solution?
>I have to use #ifdef ?

Standard headers should manage this kind of thing. Just include the headers and don't worry about it unless you discover a problem down the road.

>If yes, than how can I know what string goes after #ifdef
>for a particular library for example math.h?

That's up to you. Just use a name that isn't likely to be used by client code. This is especially important for libraries.

>I tried __MATH__, __MATH_H__, _H_MATH_ and so on
All of those are reserved by the C++ implementation. I don't recommend using them.

>My other question is that how can I use my libraries
>if I want to insert it only in my project directory.

At the very least you need to generate a library file and link to it. Otherwise you're stuck with recompiling the implementation files into the client project every time.

This article has been dead for over six months. Start a new discussion instead.