Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ambiguous symbol error?

int ii, maxnum;  
for(ii=1; ii<=num-1; ii++) {  
    if(count[ii]>max) {  // the part where I get C2872 Ambiguous Symbol error  
        max = count[ii]; // the part where I get C2872 Ambiguous Symbol error  
        maxnum = ii;  
    }  
}  

I've never gotten this error and this is frustrating.

like image 861
Haxify Avatar asked Feb 28 '12 03:02

Haxify


2 Answers

Your variable max conflicts with std::max(). Try using a different name and it ought to fix that error.

like image 111
FatalError Avatar answered Oct 15 '22 05:10

FatalError


I think the problem is not std::max() but these horrible #define's in minwindef.h:

#ifndef NOMINMAX

  #ifndef max
  #define max(a,b)            (((a) > (b)) ? (a) : (b))
  #endif

  #ifndef min
  #define min(a,b)            (((a) < (b)) ? (a) : (b))
  #endif

  #endif  /* NOMINMAX */

Use #define NOMINMAX in your project settings or stdafx.h.

like image 29
Thomas Avatar answered Oct 15 '22 05:10

Thomas