编个控制台的mysql连接程序,遇到MySQL “error C3646: 'fd': 未知重写说明符”这个问题了,按照各位前辈经验,是漏了#include <winsock.h>,但是发现加上这句也不行。实在没办法之下,把自己手打的程序全部注释,把http://blog.youkuaiyun.com/grand910616/article/details/50197859这位朋友的程序全部CTRL+C,CTRL+V,发现只报是否缺少stdafx.h了。把stdafx.h再加在第一行,发现编译过了。于是知道是stdafx.h的原因。把注释去掉,把#include <stdafx.h>这句放最前面,问题解决。
原来程序头:
#ifdef _MSC_VER
#ifdef _WIN64
#include <WinSock2.h>
#elif _WIN32
#include <winsock.h>
#endif
#endif
#include "stdafx.h"
(位置错误)
using namespace std;
#include <iostream>
#include <fstream>
#include <string>
#include <mysql.h>
修改后:
#include "stdafx.h" (位置错误)
#ifdef _MSC_VER
#ifdef _WIN64
#include <WinSock2.h>
#elif _WIN32
#include <winsock.h>
#endif
#endif
using namespace std;
#include <iostream>
#include <fstream>
#include <string>
#include <mysql.h>
参考资料:
http://blog.youkuaiyun.com/grand910616/article/details/50197859
http://www.cnblogs.com/CBDoctor/archive/2012/01/31/2333252.html等