gpt4 book ai didi

mysql - 为什么在编译 MySQL 连接测试时会出现此错误?

转载 作者:太空宇宙 更新时间:2023-11-04 13:04:44 25 4
gpt4 key购买 nike

fcts_mysql.h:

MYSQL * cmd_mysql_init();

fcts_mysql.c:

#include "fcts_mysql.h"
MYSQL *cmd_mysql_init(){
return mysql_init(NULL);
}

mysql_test.c:

#include "../lib/fcts_mysql.h"

#include <mysql.h>
#include <stdio.h>
#include <stdlib.h>


int main() {
MYSQL *cnxion;
MYSQL_RES *res;
MYSQL_ROW row;


char *server = "192.168.1.2";
char *user = "root";
char *password = "";
char *database = "test";

// cnxion = mysql_init(NULL);

cnxion = cmd_mysql_init();

if (!mysql_real_connect(cnxion, server,user, password, database, 0, NULL, 0)) {
fprintf(stderr, "%s\n 404 \n", mysql_error(cnxion));return 1;
}

if (mysql_query(cnxion, "show tables")) {
fprintf(stderr, "%s\n", mysql_error(cnxion));return 1;
}
res = mysql_use_result(cnxion);

// res = cmd_mysql_select();

printf("MySQL Tables in mysql database:\n");
// FILE *file = fopen("liste_table.txt","w");
while ((row = mysql_fetch_row(res)) != NULL){
// printf("%s \n", row[0]);fprintf(file,"%s \n",row[0]);
}
// fclose(file);
mysql_free_result(res);
mysql_close(cnxion);

return 0 ;
}
[root@xxxxx bin]# gcc  mysql_test.c $(mysql_config --libs) $(mysql_config --cflags)
In file included from mysql_test.c:1:
../lib/fcts_mysql.h:6: erreur: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token

最佳答案

MYSQL当它在 "../lib/fcts_mysql.h" 中到达时,编译器不知道它.

移动#include <mysql.h>#include "../lib/fcts_mysql.h" 前将解决问题。

关于mysql - 为什么在编译 MySQL 连接测试时会出现此错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33011333/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com