android - CLANG/GCC C 解析器将静态指针识别为函数

标签 android c gcc android-ndk clang

我正在尝试从 Batctl 2011.2.0 编译 bat-hosts.c .但是,这是 CLANG 3.1 编译器从 Android NDK 版本发出的错误消息。 8c:

bat-hosts.c:41:1: error: invalid storage class specifier in function declarator

我在同一 NDK 版本中从 GCC 4.6 收到类似的错误消息。

第 41 行显示:

static struct hashtable_t *host_hash = NULL;

指向 hashtable_t 结构(在 hash.h 中定义)的指针在任何函数外部声明为静态,并在声明时指向 NULL时间,我认为这是有效的。

我尝试将 std 选项设置为 gnu11c11gnu1xc1xc99

我的问题是:

Why are the compilers identifiying this pointer as a function declaration?

提前致谢

编辑: hashtable_t 结构定义:

struct hashtable_t {
    struct element_t **table;                   /* the hashtable itself, with the buckets */
    int elements;                               /* number of elements registered */
    int size;                                   /* size of hashtable */
    hashdata_compare_cb compare;                /* callback to a compare function.
                                                 * should compare 2 element datas for their keys,
                                                 * return 0 if same and not 0 if not same */
    hashdata_choose_cb choose;                  /* the hashfunction, should return an index based
                                                 * on the key in the data of the first argument
                                                 * and the size the second */
};

第二次编辑: 感谢大家的帮助。在按照@JonathanLeffler 的建议创建 SSCCE 之后,我发现问题与一个额外的库有关,我忘了我包括了。抱歉浪费您的时间:-/

@JonathanLeffler 如果你愿意,你可以发表回复,我会把它标记为答案。

最佳答案

根据要求:

What is the typedef for hashdata_compare_db and hashdata_choose_cb? Are there any storage classes there? Basically, you should show us an SSCCE (Short, Self-Contained, Correct Example) that reproduces the problem. All (but only) the necessary headers should be included. As far as possible, it should only use standard headers.

Often, the process of creating an SSCCE will help you resolve the problem anyway.

而且,事实上,创建 SSCCE 似乎至少让您对问题有了新的认识。

祝您顺利找到问题的其余部分。

关于android - CLANG/GCC C 解析器将静态指针识别为函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13389089/

相关文章:

c - 使用 ""初始化字符串

c - 对函数指针的 undefined reference

c++ - GCC 无法正确解析 std::accumulate

c - Mac OS X 10.7 lion 中的 setlocale

c - 有没有办法就未使用的功能发出警告?

c - 如何防止 gcc 重新排序 x86 帧指针保存/设置指令?

java - 如何从缓存文件的路径获取文件扩展名?

android - 取消选中 RadioButton 的 - 替代方法

android - 将状态栏项目(符号)的颜色更改为黑色

android - 数据库引用 vs Firebase数据库