在Linux上编译带有MySQL的C项目时出现错误:“error: unknown type name ‘uint’”。

7

这个错误会在哪些情况下出现?

我正在一个项目中尝试在Linux机器上进行MySQL连接。

我在GCC编译中包含的选项有:

gcc a.c -o a -I/usr/include/mysql -Wall -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -L/usr/lib64 -lmysqlclient -lpthread -lm -ldl

   ]$ make

gcc  -g -O3 -Wall -std=c99 -pedantic -Wformat-security -Wno-format-zero-length -Werror -Wwrite-strings -Wformat -fdiagnostics-show-option -Wextra -Wsign-compare -Wcast-align -Wno-unused-parameter -fPIC -o clitest.o -c b.c  -I/usr/include/mysql -Wall -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -L/usr/lib64 -lmysqlclient -lpthread -lm -ldl

In file included from a.h:1:0,
                 from b.c:17:
/usr/include/mysql/my_global.h:1004:1: error: unknown type name ‘ulong’
 typedef ulong nesting_map;  /* Used for flags of nesting constructs */
 ^

In file included from a.h:1:0,
                 from b.c:17:
/usr/include/mysql/my_global.h:1035:1: error: unknown type name ‘ulong’
 typedef ulong  myf; /* Type of MyFlags in my_funcs */
 ^

In file included from /usr/include/mysql/my_global.h:1062:0,
                 from a.h:1,
                 from b.c:17:
/usr/include/mysql/my_dbug.h:32:3: error: unknown type name ‘uint’
   uint level;            /* this nesting level, highest bit enables tracing */
   ^

/usr/include/mysql/my_dbug.h:49:64: error: unknown type name ‘uint’
 extern void _db_enter_(const char *_func_, const char *_file_, uint _line_,
                                                                ^

/usr/include/mysql/my_dbug.h:51:26: error: unknown type name ‘uint’
 extern  void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_);
                          ^

/usr/include/mysql/my_dbug.h:52:25: error: unknown type name ‘uint’
 extern  void _db_pargs_(uint _line_,const char *keyword);
                         ^

/usr/include/mysql/my_dbug.h:55:24: error: unknown type name ‘uint’
 extern  void _db_dump_(uint _line_,const char *keyword,
                        ^

In file included from /usr/include/mysql/mysql.h:73:0,
                 from a.h:2,
                 from b.c:17:

/usr/include/mysql/mysql_com.h:548:41: error: unknown type name ‘uint’
 void my_net_set_write_timeout(NET *net, uint timeout);
                                         ^

/usr/include/mysql/mysql_com.h:549:40: error: unknown type name ‘uint’
 void my_net_set_read_timeout(NET *net, uint timeout);
                                        ^

/usr/include/mysql/mysql_com.h:643:1: error: unknown type name ‘ulong’
 ulong STDCALL net_field_length(uchar **packet);
 ^

make: *** [clitest.o] Error 1

您IP地址为143.198.54.68,由于运营成本限制,当前对于免费用户的使用频率限制为每个IP每72小时10次对话,如需解除限制,请点击左下角设置图标按钮(手机用户先点击左上角菜单按钮)。 - iqstatic
My_global.h 是 MySQL 的标准头文件。如果我在 main() 中使用一个程序进行数据库连接,那么只需一个命令就可以正常工作,但是当我从函数调用并创建 makefile 时,就会出现错误。 - Ek1234
你能发布相关的代码和Makefile吗? - iqstatic
3个回答

4

请确保你将my_global.h放在最前面进行引用。


2
我也遇到了同样的问题。我从包含的头文件中删除了my_globals.h文件,然后我的示例程序就编译通过了。
请检查是否适用于您。

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接