开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
Mac OS
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
iostream
time.h
问题(Question):
写 C++ 突然发现的
测试程式码"untitled.cpp":
=================
#include <iostream>
using namespace std;
int main(){
clock_t TIME = clock();
printf("%f\n", (clock() - TIME)/ (double)(CLOCKS_PER_SEC));
return 0;
}
=================
编译 g++ untitled.cpp -o untitled.out 完全没警告和错误
难道include iostream 会自动 include time.h?
另外 我再测试
==========
#include <stdio.h>
int main(){
clock_t TIME = clock();
printf("%f\n", (clock() - TIME)/ (double)(CLOCKS_PER_SEC));
return 0;
}
===========
gcc untitled.cpp -o untitled.out 就会有错误讯息了
我不知道该怎么去检查 compiler 运作的方式,google 也没找到什么相关的
Mac 上是装 Xcode 就可以用 gcc
我认为是 Xcode 的 bug 导致
其他 IDE 都拿 Xcode 装的 gcc 来编译 所以都一样的结果
预期的正确结果(Expected Output):
产生错误讯息
错误结果(Wrong Output):
完全正确
程式码(Code):(请善用置底文网页, 记得排版)
补充说明(Supplement):
Xcode 有同样问题 Code::block 也有同样问题