Lars Gyrup Brink Nielsen
Lars Gyrup Brink Nielsen

Reputation: 4095

CLANG/GCC C parser identifies static pointer as function

I'm trying to compile bat-hosts.c from Batctl 2011.2.0. However, this is an error message emitted by the CLANG 3.1 compiler from Android NDK rev. 8c:

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

I get a similar error message from GCC 4.6 in the same NDK rev.

Line 41 reads:

static struct hashtable_t *host_hash = NULL;

This pointer to a hashtable_t struct (defined in hash.h) is declared as static outside any function and pointed to NULL at declaration time, which I find to be valid.

I tried running GCC/CLANG with std option set to gnu11, c11, gnu1x, c1x, and c99.

My question is:

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

Thanks in advance

EDIT: hashtable_t struct definition:

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 */
};

2nd EDIT: Thank you all for your help. After creating an SSCCE as proposed by @JonathanLeffler, I discovered that the problem had something to to with an additional library, I forgot that I included. Sorry for wasting your time :-/

@JonathanLeffler you can post a reply if you want to and I will mark it as the answer.

Upvotes: 1

Views: 424

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 753805

As requested:

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.

And, indeed, it seems that creating an SSCCE has at least given you a new perspective on your problem.

Good luck with tracking down the rest of the issue.

Upvotes: 1

Related Questions