C++编译时遇到的一个很诡异的错误。C/C++ code#include stdio.h#include iostream#include windows.h
C++编译时遇到的一个很诡异的错误。
- C/C++ code
#include <stdio.h>#include <iostream>#include <windows.h>class WidgetObject{ int m_x; int m_y;public: WidgetObject(int _x,int _y=5):m_x(_x),m_y(_y) { } void ShowValue() { std::cout<<m_x<<" "<<m_y<<std::endl; } int GetXValue() { return m_x; } int GetYValue() { return m_y; }};int main(int argc, char **argv){ printf("hello world\n"); return 0;}不知道为什么。g++下要把#include <windows.h>注释掉才能通过编译。
[解决办法]
报什么错啊?
不会是找不到“windows.h”没有吧,这个文件只有在windows平台下才用的系统头文件,在linux/unix下是没有的。
[解决办法]
windows.h不属于ANSI C的标准库,GCC是不包含的。
[解决办法]
问题找到了那就我接分了。其实没有必要引入windows头文件的。
[解决办法]
问题找到了那就我接分了。看到你的程序其实没有必要引入windows头文件的。
[解决办法]
问题找到了那就我接分了。看到你的程序其实没有必要引入windows头文件的。
