PiRSquared17 / sire

Automatically exported from code.google.com/p/sire
0 stars 0 forks source link

Compilation error when trying to use pow #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. double x = pow( double y,  1/6. );
2.
3.

What is the expected output? What do you see instead?
would expect the code to return x = y**(1/6.)
but get a compilation error

/home/julien/software/devel/sire/corelib/src/libs/SireIO/amber.cpp: In member 
function ‘SireMol::Molecules SireIO::Amber::readcrdtop(const QString&, const 
QString&)’:
/home/julien/software/devel/sire/corelib/src/libs/SireIO/amber.cpp:837: error: 
call of overloaded ‘pow(double, double)’ is ambiguous
/usr/include/bits/mathcalls.h:154: note: candidates are: double pow(double, 
double)

Note that double x = std::pow( double y,  1/6. ); works 
Please use labels and text to provide additional information.

Original issue reported on code.google.com by julienm...@googlemail.com on 20 Oct 2010 at 3:17

GoogleCodeExporter commented 9 years ago
This is a problem with how I've used namespaces in Sire. SireMaths::pow is 
brought into the global namespace when you write "using namespace SireMaths;", 
and so it clashes with std::pow, which was brought in by "using namespace 
std;". In these cases, you have to choose either SireMaths::pow, or as you have 
done, std::pow.

Original comment by chryswo...@gmail.com on 10 May 2013 at 11:09