【发布时间】:2012-03-10 02:55:23
【问题描述】:
我在尝试编译以下代码时遇到编译错误。
#include "my_global.h"
#include "mysql.h"
int main(void)
{
MYSQL *conn;
conn = mysql_init(NULL);
if (conn == NULL) {
printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
exit(1);
}
if (mysql_real_connect(conn, "localhost", "zetcode",
"passwd", NULL, 0, NULL, 0) == NULL) {
printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
exit(1);
}
if (mysql_query(conn, "create database testdb")) {
printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
exit(1);
}
mysql_close(conn);
return 0;
}
我在 Windows 7 上使用 Borland 32 位编译器来编译以下代码。我的编译命令如下所示
c:\Borland\BCC55>bcc32 -Ic:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2
-win32-vs2005\include -c creatingTESTDB.c
我收到六个编译错误:
Borland C++ 5.5.1 for Win32 版权所有 (c) 1993, 2000 Borland createdTESTDB.c:
警告 W8017 c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs20 05\include\config-win.h 111: 'S_IRWXU' 的重新定义不是 相同
错误 E2238 c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005 \include\config-win.h 114: 'mode_t' 的多重声明
错误 E2344 c:\Borland\Bcc55\include\sys/types.h 35:较早 'mod e_t' 的声明
错误 E2141 c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005 \include\config-win.h 265:函数中的声明语法错误 double2ulonglong
错误 E2378 c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005 \include\config-win.h 268: 缺少返回语句;在功能上 double2ulonglo ng
错误 E2293 c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005 \include\my_global.h 1591:) 函数 rint
中预期错误 E2293 c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005 \include\my_global.h 1595:) 函数 rint
* 编译时出现 6 个错误 *
任何帮助将不胜感激。 我在尝试编译以下代码时遇到编译错误。
#include "my_global.h"
#include "mysql.h"
int main(void)
{
MYSQL *conn;
conn = mysql_init(NULL);
if (conn == NULL) {
printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
exit(1);
}
if (mysql_real_connect(conn, "localhost", "zetcode",
"passwd", NULL, 0, NULL, 0) == NULL) {
printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
exit(1);
}
if (mysql_query(conn, "create database testdb")) {
printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
exit(1);
}
mysql_close(conn);
return 0;
}
我在 Windows 7 上使用 Borland 32 位编译器来编译以下代码。我的编译命令如下所示
c:\Borland\BCC55>bcc32 -Ic:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2
-win32-vs2005\include -c creatingTESTDB.c
我收到六个编译错误:
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
creatingTESTDB.c:<br> Warning W8017
c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs20
05\include\config-win.h 111: Redefinition of 'S_IRWXU' is not
identical<br><br> Error E2238
c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005
\include\config-win.h 114: Multiple declaration for 'mode_t'<br><br>
Error E2344 c:\Borland\Bcc55\include\sys/types.h 35: Earlier
declaration of 'mod e_t'<br><br> Error E2141
c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005
\include\config-win.h 265: Declaration syntax error in function
double2ulonglong<br><br> Error E2378
c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005
\include\config-win.h 268: Return statement missing ; in function
double2ulonglo ng<br><br> Error E2293
c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005
\include\my_global.h 1591: ) expected in function rint<br><br> Error
E2293
c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005
\include\my_global.h 1595: ) expected in function rint<br><br>
*** 6 errors in Compile ***
我该如何解决这个问题?
【问题讨论】: