Bugzilla – Bug 2171
power-adaptation-distance.cc:202:22: error: call to 'pow' is ambiguous
Last modified: 2015-08-25 09:48:54 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) ^
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
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.
Hi. It's a bug, actualPower should be a double. John please try this patch, I can't reproduce the problem on my platform.
Created attachment 2125 [details] Change actualPower map from uint32_t to double
(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
(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.
Created attachment 2126 [details] power adaptation distance patch
Created attachment 2127 [details] power adaptation interference patch This patch is for the other example where the function pow is used.
http://code.nsnam.org/ns-3-dev/rev/00752c4140a9