Clang模糊调用(int,float,double)

时间:2013-07-13 23:54:39

标签: c++ macos clang ambiguous

我必须使用Clang在Mac上编译API,它使用类似于此的构造:

#define TRUE 1

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

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

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

func(TRUE);

Clang抱怨说func()的呼叫含糊不清,而MSVC和GCC则没有。 Clang是否有选择在这种情况下会选择整数变量?

编辑:这是编译的原始输出

../../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是一个整数类型,SReal是浮点类型。

1 个答案:

答案 0 :(得分:0)

我有时间调查更多时间查看原始构建项目并发现我缺少编译器选项。有趣的是,它只会产生额外的定义,似乎解决了“模棱两可”。

-include _api/ge_mac_flags.h

看起来像

#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

解决它!

相关问题