<分区>
当我包含 my_global.h 时,我无法编译代码。
这不应该是一个主要功能,因为之前的数据是由另一个 c 文件中的代码“收集”的,与这个一起将成为程序(使用外部变量,这还不在代码中)。
我的问题是当函数不是“main”时我无法编译代码。我在下面做了一个非常简单的示例,所以如果我在下面的示例中将“void test() {”替换为“void main() {”,编译就可以了。保留“test”但删除#include my_global.h 也可以。但是在最终代码中我当然需要 my_global.h,所以我不能删除它。所以 not main 和 my_global.h 的组合给了我这个问题。
#include <my_global.h>
#include <mysql.h>
#include <stdlib.h>
#include <stdio.h>
#include "extvar.h"
void test() {
printf("Testing testing\n");
}
我正在使用 $ gcc -c testa.c -o testa.o 'mysql_config --cflags --libs'
进行编译。
错误信息:
In file included from testa.c:1:0:
/usr/include/mysql/my_global.h:478:21: error: expected identifier or ‘(’ before ‘)’ token
#define test(a) ((a) ? 1 : 0)
^
testa.c:7:6: note: in expansion of macro ‘test’
void test() {
^
非常感谢您的帮助。