Does <algorithm> <cmath> include?
The following program compiles correctly:
#include <algorithm>
int main(int argc, char *argv[]) {
return int(log(23.f));
}
(under g ++ 4.9.2 with flag -std=c++11)
The code uses a function logthat is defined on <cmath>. However, it does not include a heading <cmath>, but only a heading <algorithm>. Why g++doesn't it give any warnings and compiles code correctly?
+4
3 answers
:
g++ ?
, , lib++ ; export * , " , , ". std.algorithm, std.cmath, , , std.algorithm, std.cmath.
, " " , -fmodules .
clang- lib++ , , clang , :
main.cpp: 5: 16: : "log" "Darwin.C.math"
return int(log(23.f)); ^/usr/include/math.h:387:15: note:
extern double log(double); ^1 .
lib++ <algorithm> <cmath>, <random>. , , , .
+2