Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the C++/CLI compiler get confused so easily with symbols?

Tags:

c++-cli

Here is my code:

using namespace System;
using namespace System::Collections;
using namespace System::Collections::Generic;

namespace Tests {
    ref class MyCollection : public IEnumerable<int> <----HERE!

The C# compiler, for instance, will recognize that the only IEnumerable<T> it has in those namespaces is from System::Collections::Generic. Why can't the C++/CLI compiler do the same? Unlesss I type its full name or at least Generic::IEnumerable<int>, it won't recognize it and will fire a C2872 error: ambiguous symbol.

Am I missing something here?

like image 425
devoured elysium Avatar asked Sep 24 '09 06:09

devoured elysium


1 Answers

Given your namespaces IEnumerable is ambiguous

MS define IEnumerable in both System::Collections and System::Collections::Generic which of the 2 do you want your code to use?

like image 159
mmmmmm Avatar answered Oct 23 '22 06:10

mmmmmm