title: What causes ambiguous symbol errors? C++
body: <p>I am trying to learn C++ by doing a small windows phone app. Currently I am just following a tutorial to get to grips with developing for the windows phone. However, I have encountered a ambiguous signal error when trying to build the code. I am used to the niceties associated with Java and am a bit lost as to what could be causing this error. The error dump I get is:</p>
  
  <pre><code>1&gt;c:\program files (x86)\windows phone kits\8.0\include\wrl\event.h(740): error C2872:        'EventRegistrationToken' : ambiguous symbol
  1&gt;          could be 'c:\program files (x86)\windows phone kits\8.0\include\eventtoken.h(51) : EventRegistrationToken'
  1&gt;          or       'c:\program files (x86)\windows phone kits\8.0\windows metadata\windows.winmd : Windows::Foundation::EventRegistrationToken'
  1&gt;          c:\program files (x86)\windows phone kits\8.0\include\wrl\event.h(1035) : see reference to class template instantiation 'Microsoft::WRL::EventSource&lt;TDelegateInterface&gt;' being compiled
  1&gt;c:\program files (x86)\windows phone kits\8.0\include\wrl\event.h(814): error C2872: 'EventRegistrationToken' : ambiguous symbol
  1&gt;          could be 'c:\program files (x86)\windows phone kits\8.0\include\eventtoken.h(51) : EventRegistrationToken'
  1&gt;          or       'c:\program files (x86)\windows phone kits\8.0\windows metadata\windows.winmd : Windows::Foundation::EventRegistrationToken'
  </code></pre>
  
  <p>The code is attached below - sorry for giving the whole file, but I literally dont know where to start. Any help would be greatly appreciated.</p>
  
  <p>Thanks</p>
  
  <pre><code>#include "pch.h"
  #include "WindowsPhoneGame.h"
  #include "BasicTimer.h"
  //#include &lt;string.h&gt;
  #include &lt;sstream&gt;
  
  //using namespace std;
  using namespace Windows::ApplicationModel;
  using namespace Windows::ApplicationModel::Core;
  using namespace Windows::ApplicationModel::Activation;
  using namespace Windows::UI::Core;
  using namespace Windows::System;
  using namespace Windows::Foundation;
  using namespace Windows::Graphics::Display;
  using namespace concurrency;
  
  
  WindowsPhoneGame::WindowsPhoneGame() :
  m_windowClosed(false),
  m_windowVisible(true)
  {
  }
  
  void WindowsPhoneGame::Initialize(CoreApplicationView^ applicationView)
  {
  applicationView-&gt;Activated +=
      ref new TypedEventHandler&lt;CoreApplicationView^, IActivatedEventArgs^&gt;(this,   &amp;WindowsPhoneGame::OnActivated);
  
  CoreApplication::Suspending +=
      ref new EventHandler&lt;SuspendingEventArgs^&gt;(this, &amp;WindowsPhoneGame::OnSuspending);
  
  CoreApplication::Resuming +=
      ref new EventHandler&lt;Platform::Object^&gt;(this, &amp;WindowsPhoneGame::OnResuming);
  
  m_renderer = ref new Renderer();
  }
  
  void WindowsPhoneGame::SetWindow(CoreWindow^ window)
  {
  window-&gt;VisibilityChanged +=
      ref new TypedEventHandler&lt;CoreWindow^, VisibilityChangedEventArgs^&gt;(this,  &amp;WindowsPhoneGame::OnVisibilityChanged);
  
  window-&gt;Closed += 
      ref new TypedEventHandler&lt;CoreWindow^, CoreWindowEventArgs^&gt;(this,  &amp;WindowsPhoneGame::OnWindowClosed);
  
  window-&gt;PointerPressed +=
      ref new TypedEventHandler&lt;CoreWindow^, PointerEventArgs^&gt;(this, &amp;WindowsPhoneGame::OnPointerPressed);
  
  window-&gt;PointerMoved +=
      ref new TypedEventHandler&lt;CoreWindow^, PointerEventArgs^&gt;(this, &amp;WindowsPhoneGame::OnPointerMoved);
  
  window-&gt;PointerReleased +=
      ref new TypedEventHandler&lt;CoreWindow^, PointerEventArgs^&gt;(this, &amp;WindowsPhoneGame::OnPointerReleased);
  
  m_renderer-&gt;Initialize(CoreWindow::GetForCurrentThread());
  }
  
  void WindowsPhoneGame::Load(Platform::String^ entryPoint)
  {
  }
  
  void WindowsPhoneGame::Run()
  {
  BasicTimer^ timer = ref new BasicTimer();
  
  while (!m_windowClosed)
  {
      if (m_windowVisible)
      {
          timer-&gt;Update();
          CoreWindow::GetForCurrentThread()-&gt;Dispatcher- &gt;ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
          m_renderer-&gt;Update(timer-&gt;Total, timer-&gt;Delta);
          m_renderer-&gt;Render();
          m_renderer-&gt;Present(); // This call is synchronized to the display frame rate.
      }
      else
      {
          CoreWindow::GetForCurrentThread()-&gt;Dispatcher-&gt;ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
      }
  }
  }
  
  void WindowsPhoneGame::Uninitialize()
  {
  }
  
  void WindowsPhoneGame::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
  {
  m_windowVisible = args-&gt;Visible;
  }
  
  void WindowsPhoneGame::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
  { 
  m_windowClosed = true;
  }
  
  void WindowsPhoneGame::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
  {
  ostringstream sstream;
  sstream &lt;&lt; "Pressed at: " &lt;&lt; "X: " &lt;&lt; args-&gt;CurrentPoint-&gt;Position.X &lt;&lt; " Y: " &lt;&lt; args-&gt;CurrentPoint-&gt;Position.Y &lt;&lt; "\n";
  string s = sstream.str();
  OutputDebugStringA(s.c_str());
  }
  
  void WindowsPhoneGame::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
  {
  ostringstream sstream;
  sstream &lt;&lt; "Moved at: " &lt;&lt; "X: " &lt;&lt; args-&gt;CurrentPoint-&gt;Position.X &lt;&lt; " Y: " &lt;&lt;  args-&gt;CurrentPoint-&gt;Position.Y &lt;&lt; "\n";
  string s = sstream.str();
  OutputDebugStringA(s.c_str());
  }
  
  void WindowsPhoneGame::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
  {
      ostringstream sstream;
  sstream &lt;&lt; "Released at: " &lt;&lt; "X: " &lt;&lt; args-&gt;CurrentPoint-&gt;Position.X &lt;&lt; " Y: " &lt;&lt; args-&gt;CurrentPoint-&gt;Position.Y &lt;&lt; "\n";
  string s = sstream.str();
  OutputDebugStringA(s.c_str());
  }
  
  void WindowsPhoneGame::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
  {
  CoreWindow::GetForCurrentThread()-&gt;Activate();
  }
  
  void WindowsPhoneGame::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
  {
  // Save app state asynchronously after requesting a deferral. Holding a deferral
  // indicates that the application is busy performing suspending operations. Be
  // aware that a deferral may not be held indefinitely. After about five seconds,
  // the app will be forced to exit.
  SuspendingDeferral^ deferral = args-&gt;SuspendingOperation-&gt;GetDeferral();
  m_renderer-&gt;ReleaseResourcesForSuspending();
  
  create_task([this, deferral]()
  {
      // Insert your code here.
  
      deferral-&gt;Complete();
  });
  }
  
  void WindowsPhoneGame::OnResuming(Platform::Object^ sender, Platform::Object^ args)
  {
  // Restore any data or state that was unloaded on suspend. By default, data
  // and state are persisted when resuming from suspend. Note that this event
  // does not occur if the app was previously terminated.
   m_renderer-&gt;CreateWindowSizeDependentResources();
  }
  
  IFrameworkView^ Direct3DApplicationSource::CreateView()
  {
  return ref new WindowsPhoneGame();
  }
  
  [Platform::MTAThread]
  int main(Platform::Array&lt;Platform::String^&gt;^)
  {
  auto direct3DApplicationSource = ref new Direct3DApplicationSource();
  CoreApplication::Run(direct3DApplicationSource);
  return 0;
  }
  </code></pre>