Here is the source:
> cat ambiguous.cpp
#include <iostream>
#define MY_DEFINE -0.65 //call of overloaded ‘calcPos(float [3], NULL, float [3], float [3], int, int, double)’ is ambiguous
//#define MY_DEFINE -0.65f //Compiles
void calcPos( float xyzDst[3], float hprDst[3],
const float xyzSrc[3], const float hprSrc[3],
float ox, float oy, float oz, float oh_=0.0f, float op_=0.0f, float or_=0.0f );
void calcPos( float xyzDst[3], float hprDst[3],
const float xyzSrc[3], const float hprSrc[3],
const float xyzOffset[3], const float hprOffset[3], bool debug=false );
int main( void )
{
float xyz[3];
float hpr[3];
calcPos( xyz, NULL, xyz, hpr, 0, 0, MY_DEFINE );
}
void calcPos( float xyzDst[3], float hprDst[3],
const float xyzSrc[3], const float hprSrc[3],
float ox_, float oy_, float oz_,
float oh_, float op_, float or_ )
{
return;
}
void calcPos( float xyzDst[3], float hprDst[3],
const float xyzSrc[3], const float hprSrc[3],
const float xyzOffset[3], const float hprOffset[3], bool debug )
{
if ( debug )
{
std::cout << "Debug Info" << std::endl;
}
return;
}
Here is the error:
> g++ ambiguous.cpp
ambiguous.cpp: In function ‘int main()’:
ambiguous.cpp:19:54: error: call of overloaded ‘calcPos(float [3], NULL, float [3], float [3], int, int, double)’ is ambiguous
calcPos( xyz, NULL, xyz, hpr, 0, 0, MY_DEFINE );
^
ambiguous.cpp:6:10: note: candidate: ‘void calcPos(float*, float*, const float*, const float*, float, float, float, float, float, float)’
void calcPos( float xyzDst[3], float hprDst[3],
^~~~~~~
ambiguous.cpp:10:10: note: candidate: ‘void calcPos(float*, float*, const float*, const float*, const float*, const float*, bool)’
void calcPos( float xyzDst[3], float hprDst[3],
^~~~~~~
I solved the error by setting:
#define MY_DEFINE -0.65f
However, I don't understand why this was even necessary.
It also compiled fine before I added the bool debug parameter.
Can someone explain?