Bug 2171 - power-adaptation-distance.cc:202:22: error: call to 'pow' is ambiguous
power-adaptation-distance.cc:202:22: error: call to 'pow' is ambiguous
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: examples
ns-3-dev
PC Mac OS
: P3 normal
Assigned To: Matías Richart
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-23 15:32 UTC by John Abraham
Modified: 2015-08-25 09:48 UTC (History)
2 users (show)

See Also:


Attachments
Change actualPower map from uint32_t to double (527 bytes, patch)
2015-08-24 10:28 UTC, Matías Richart
Details | Diff
power adaptation distance patch (888 bytes, patch)
2015-08-24 14:05 UTC, Matías Richart
Details | Diff
power adaptation interference patch (1.02 KB, patch)
2015-08-24 14:06 UTC, Matías Richart
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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