cancel
Showing results for 
Search instead for 
Did you mean: 

Namespace for cube programmer API

TMack.1
Associate II

I am using the cube programmer API in a Qt C++ windows application and hit a problem where there is clash in naming of the disconnect() function. 

disconnect() is in both qobject.h and CubeProgrammer_API.h

I am not a C++ expert, so please tell me if I have something wrong, however my understanding is that I would normally deal with this using namespaces. However I see no namespace defined in CubeProgrammer_API.h.

I have worked around this by modifying CubeProgrammer_API.h to include a namespace. eg

 

#ifndef CUBEPROGRAMMER_API_H
#define CUBEPROGRAMMER_API_H

namespace CubeProgAPI
{
#ifdef __cplusplus
extern "C" {
#endif
.
.
.
#ifdef __cplusplus
}
#endif
}

 

This allow me to call the functions using the namespace ( eg  CubeProgAPI::disconnect(); ) and it does build without error but my understanding is that is not correct as the CubeProgrammer_API.lib I am linking against does not have the namespace. In fact I don't understand why it doesn't failed to link as I am using a namespace the linker will not recognise?

So my questions are:
1) Am I correct that CubeProgrammer_API does not have a namespace, it is just straight C code?
2) Am I correct that my solution above is not a good idea, even if it appears to work?
3) Any other "proper" solution to this name clash?
On that last point, I guess I could generate my own C++ library (with namespace) as a wrapper around the CubeProgrammer_API but I would rather avoid this if possible.

0 REPLIES 0