Today, I checked mysql database + vc to connect to the database. As a result, I used the mfc application Wizard to create a project and then added # include "mysql. h "(environment already set), a lot of errors occur during compilation, as shown below:
Compiling...
StdAfx. cpp
C: mysqlincludemysql_com.h (116): error C2146: syntax error: missing '; 'before identifier' fd'
C: mysqlincludemysql_com.h (116): error C2501: 'socket ': missing storage-class or type specifiers
C: mysqlincludemysql_com.h (116): error C2501: 'fd ': missing storage-class or type specifiers
C: mysqlincludemysql_com.h (180): error C2065: 'socket ': undeclared identifier
C: mysqlincludemysql_com.h (180): error C2146: syntax error: missing ') 'Before identifier's'
C: mysqlincludemysql_com.h (181): error C2059: syntax error :')'
Error executing cl.exe.
After searching for a long time on the Internet and failing to find the answer, I checked examples in the mysql root directory. Is there a project written in c ++? I debugged it, I think mysql can be compiled. h. There will be no errors in this file. It should be the include conflict during compilation, so I will put stdafx. h. delete several lines of the file. When I block the # define WIN32_LEAN_AND_MEAN statements, I can compile the file. I also tried mysql_init (MYSQL *) 0 ); this function is correct. so the problem lies in define WIN32_LEAN_AND_MEAN.
# Define WIN32_LEAN_AND_MEAN indicates that the compiler should not contain MFC-related operations. (Just a good exercise-if you are not using MFC) And we include dxutil. h and ddutil. h, which are two useful header files. They allow you to work in a way that is easier than the usual DirectX programming.
Why # define WIN32_LEAN_AND_MEAN.
The answer is very simple, because I want to include content that is as concise as possible. It is much faster to compile this sentence.