Sign in to follow this  
supagu

linking with conflicting headers

Recommended Posts

well, i hate having to put my own code in a namespace, and have been writing a plugin for 3d max, and out class names are conflicting as my math library has a Matrix3 and 3d max has a Matrix3, so what i've done in the past is to put namespace in all the max headers around the use of matrix3. This has always worked fine, up till the other day when i went to use a 3d max function and it decided it couldnt find the function to link with as it was like: void SomeFn(MaxSDK::Matrix3 matrix); where the library would have been built like so: void SomeFn(Matrix3 matrix); is there some trick i can do to get it to tell the linker to ignore the MaxSDK or some other suggestion for seperating max headers so they dont conflict with my own code without having to go namespace'ing up all of my code?

Share this post


Link to post
Share on other sites
First of all I'm assuming that the Max SDK is distrubuted as a precompiled static or dynamic library.

So correct me If I'm wrong, but it sounds like you just went into the Max SDK headers and introduced a namespace. That won't work. The static library distributed with the Max SDK knows nothing about that namespace and will result in all sorts of linker errors.

Basically you're going about resolving your name clashing problem all wrong. The whole point of namespaces is to resolve the name clashing problem that was left over from C. There is nothing 'bad' or 'ugly' about them, and you should be using namespace all the time.

Simply add a namespace to your code.

Share this post


Link to post
Share on other sites
Quote:
Original post by fpsgamer
First of all I'm assuming that the Max SDK is distrubuted as a precompiled static or dynamic library.

So correct me If I'm wrong, but it sounds like you just went into the Max SDK headers and introduced a namespace. That won't work. The static library distributed with the Max SDK knows nothing about that namespace and will result in all sorts of linker errors.

Basically you're going about resolving your name clashing problem all wrong. The whole point of namespaces is to resolve the name clashing problem that was left over from C. There is nothing 'bad' or 'ugly' about them, and you should be using namespace all the time.

Simply add a namespace to your code.


QFT. Namespace conflicts happen, and I'm surprised that the SDK doesn't already have a namespace in place. You should definitely use a namespace within your own projects, and it doesn't have to ugly up your code. Just toss in "using my_ns;" wherever appropriate.

You should also be able to create a redefinition header, something like the following:


// MaxSDK redefinition
#include "maxsdk.h" // or whatever

namespace MaxSDK
...
typedef MaxSDK::Matrix3 Matrix3;



This will help clear up ambiguity, but it won't help you make your Matrix3 not conflict in names.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this