This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

reference to 'std' is ambiguous

Hi,

I'm using ti_cgt_tiarmclang_2.1.2.LTS.

I have C++ code:

#include <type_traits> 

template <typename T, const T VALUE>
struct integral_constant : std::integral_constant<T, VALUE> {};

but I get an error:

error: reference to 'std' is ambiguous

What am I missing here ?

Thanks,

Eli

  • With TI Clang v2.1.3.LTS and pasting your code into an empty source file can't repeat the error.

    Based on searches (Reference to ' ' is ambiguous and Compiler Error C2872) your "error: reference to 'std' is ambiguous" error could be caused by use of using namespace std in either your source code or an include file.

    You could try changing from:

    struct integral_constant : std::integral_constant<T, VALUE> {};

    To:

    struct integral_constant : ::std::integral_constant<T, VALUE> {};

    Where the leading :: in front of std uses  ::std::integral_constant from the global namespace.

  • Hi,

    Yes it helps but I didn't understand why.

    Why there are many std ? 

    Thanks,

    Eli

  • Why there are many std ? 

    Is "error: reference to 'std' is ambiguous" the full error message, or was there some more diagnostic information reported by the compiler?

    E.g. I took the example code from reference to function is ambiguous in c++ and the full error reported by TI Clang v2.1.3.LTS was:

    Building file: "../test.cpp"
    Invoking: Arm Compiler
    "/home/mr_halfword/ti/ccs1230/ccs/tools/compiler/ti-cgt-armllvm_2.1.3.LTS/bin/tiarmclang" -c -march=armv7r -mcpu=cortex-r5 -mbig-endian -Og -I"/home/mr_halfword/workspace_v12/AM2634_CPP" -I"/home/mr_halfword/ti/ccs1230/ccs/tools/compiler/ti-cgt-armllvm_2.1.3.LTS/include" -g -MMD -MP -MF"test.d_raw" -MT"test.o"   -o"test.o" "../test.cpp"
    subdir_rules.mk:14: recipe for target 'test.o' failed
    ../test.cpp:19:5: error: reference to 'greater' is ambiguous
        greater(a,b,c);
        ^
    ../test.cpp:10:6: note: candidate found by name lookup is 'greater'
    void greater(int num1, int num2, int num3);
         ^
    /home/mr_halfword/ti/ccs1230/ccs/tools/compiler/ti-cgt-armllvm_2.1.3.LTS/include/c++/v1/__functional/operations.h:584:29: note: candidate found by name lookup is 'std::greater'
    struct _LIBCPP_TEMPLATE_VIS greater
                                ^
    1 error generated.
    gmake: *** [test.o] Error 1
    gmake: Target 'all' not remade because of errors.
    

    I.e. for the above example TI Clang identified the source of the ambiguity.

  • Hi,

    I understand the example.

    In my case the code was originally compiled with GCC and now I'm porting it to CLANG so the error is not so elaborated.

    Thanks,

    Eli