Bug 2171

Summary: power-adaptation-distance.cc:202:22: error: call to 'pow' is ambiguous
Product: ns-3 Reporter: John Abraham <john.abraham.in>
Component: examplesAssignee: Matías Richart <mrichart>
Status: RESOLVED FIXED    
Severity: normal CC: matis18, tomh
Priority: P3    
Version: ns-3-dev   
Hardware: PC   
OS: Mac OS   
Attachments: Change actualPower map from uint32_t to double
power adaptation distance patch
power adaptation interference patch

Description John Abraham 2015-08-23 15:32:11 UTC
../examples/wireless/power-adaptation-distance.cc:202:22: error: call to 'pow' is ambiguous
      totalEnergy += pow (10, actualPower[dest] / 10) * GetCalcTxTime (actualMode[dest]).GetSeconds ();
                     ^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/math.h:443:15: note: candidate function
extern double pow(double, double);
              ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/cmath:357:3: note: candidate function
  pow(float __x, float __y)
  ^
Comment 1 John Abraham 2015-08-23 15:33:05 UTC
g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
Comment 2 Tom Henderson 2015-08-23 18:01:09 UTC
I believe that explicitly casting one of the arguments to either float or double will resolve it.  However, at present it looks like it is performing integer division, so perhaps Matias should recommend a solution.
Comment 3 Matías Richart 2015-08-24 10:27:04 UTC
Hi.
It's a bug, actualPower should be a double.
John please try this patch, I can't reproduce the problem on my platform.
Comment 4 Matías Richart 2015-08-24 10:28:11 UTC
Created attachment 2125 [details]
Change actualPower map from uint32_t to double
Comment 5 John Abraham 2015-08-24 13:32:36 UTC
(In reply to Matías Richart from comment #4)
> Created attachment 2125 [details]
> Change actualPower map from uint32_t to double

well i tried that

../examples/wireless/power-adaptation-interference.cc:198:22: error: call to 'pow' is ambiguous
      totalEnergy += pow(10, actualPower[dest] / 10) * GetCalcTxTime (actualMode[dest]).GetSeconds ();
                     ^~~

But I tried 

      totalEnergy += pow (10.0, actualPower[dest] / 10.0) * GetCalcTxTime (actualMode[dest]).GetSeconds ();


and it compiled
Comment 6 Matías Richart 2015-08-24 14:04:34 UTC
(In reply to John Abraham from comment #5)
> (In reply to Matías Richart from comment #4)
> > Created attachment 2125 [details]
> > Change actualPower map from uint32_t to double
> 
> well i tried that
> 
> ../examples/wireless/power-adaptation-interference.cc:198:22: error: call to
> 'pow' is ambiguous
>       totalEnergy += pow(10, actualPower[dest] / 10) * GetCalcTxTime
> (actualMode[dest]).GetSeconds ();
>                      ^~~
> 
> But I tried 
> 
>       totalEnergy += pow (10.0, actualPower[dest] / 10.0) * GetCalcTxTime
> (actualMode[dest]).GetSeconds ();
> 
> 
> and it compiled

Ok. Great!
I attach a patch for this and for the other example where pow is used. Can you please test the changes? Thanks.
Comment 7 Matías Richart 2015-08-24 14:05:43 UTC
Created attachment 2126 [details]
power adaptation distance patch
Comment 8 Matías Richart 2015-08-24 14:06:22 UTC
Created attachment 2127 [details]
power adaptation interference patch

This patch is for the other example where the function pow is used.
Comment 9 John Abraham 2015-08-25 09:48:54 UTC
http://code.nsnam.org/ns-3-dev/rev/00752c4140a9