I'm using Qt 4.1.0 Open Source on Windows XP and haven't been able to use the fmod() function from within a dialog box method. A different post talks about adding options to the gcc command line, but I don't see how that applies to my config.
I'm using Qt 4.1.0 Open Source on Windows XP and haven't been able to use the fmod() function from within a dialog box method. A different post talks about adding options to the gcc command line, but I don't see how that applies to my config.
In what way you "haven't been able" to use it? What did the compiler complain about?
The error message was:
fmod' undeclared (first use this function)
At the beginning of the cpp file, I have this stmt
#include <cmath.h>
Thanks,
Try:
Either:
or:Qt Code:
#include <math.h> a = fmod(x,y);To copy to clipboard, switch view to plain text mode
Qt Code:
#include <cmath> a = ::fmod(x,y);To copy to clipboard, switch view to plain text mode
Great!
I don't understand why including cmath.h doesn't work, but including cmath does, but for now I'm happy.
Thanks.
Because there is no such header as "cmath.h". All standard C++ headers don't have a customary ".h" extension.Originally Posted by awbaker
Sure enough - I checked the mingw include library and none of the files have the .h extension. The confusion factor comes with the Qt include library where all files DO have the .h extension.
Not quite, in Qt4 both versions are available, but the one without ".h" is preferred.Originally Posted by awbaker
The C++ standard says that if you use #include <foo.h> that there is an actual file someplace called foo.h
Using the notation #include <foo> makes no assumption about the storage of the "foo" library, it just guarantees the availability of the foo functions to your program.
Also, the practical difference of <math.h> vs <cmath> is that the formers functions are automatically imported to the current namespace, while the latters aren't.
Bookmarks