Вопрос

I have to compile an API on Mac using Clang that uses a construct similar to this:

#define TRUE 1

void func(int a) {
    // ...
}

void func(double a) {
    // ...
}

void func(float a) {
    // ...
}

func(TRUE);

Clang complains that the call to func() is ambiguous while MSVC and GCC don't. Is there an option for Clang that it will choose the integer variant in this case?

Edit: This is the original output of the compilation

../../resource/_api/c4d_basedocument.cpp:263:52: error: conversion from 'int' to 'const GeData' is ambiguous
        this->SetParameter(DescLevel(DOCUMENT_USERCHANGE),TRUE,DESCFLAGS_SET_DONTCHECKMINMAX);
                                                          ^~~~
../../resource/_api/ge_sys_math.h:21:15: note: expanded from macro 'TRUE'
        #define TRUE    1
                        ^
../../resource/_api/c4d_gedata.h:97:3: note: candidate constructor
                GeData(double n)
                ^
../../resource/_api/c4d_gedata.h:110:3: note: candidate constructor
                GeData(LONG n)
                ^
../../resource/_api/c4d_gedata.h:116:3: note: candidate constructor
                GeData(SReal n)
                ^

LONG is an integral type, SReal a floating point type.

Это было полезно?

Решение

I had time to investigate more time in looking into the original build project and see that I was missing a compiler option. Interesting thing is, that it only results in additional definitions set which seems to solve the "ambiguousity".

-include _api/ge_mac_flags.h

Which looks like

#ifndef __GE_MAC_FLAGS__
#define __GE_MAC_FLAGS__

#define __MAC
#define __DEBUGGING__                                                                               // avoid conflicts with DebugAssert() definition for the Mac

#if __LP64__
    #define __C4D_64BIT
#endif

#endif

Solves it!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top