troydhanson / uthash

C macros for hash tables and more
Other
4.18k stars 926 forks source link

Error after macro substitution: Struct 'UT_hash_handle' doesn't have a field 'hh_prev' #138

Closed silvioprog closed 6 years ago

silvioprog commented 6 years ago

Hello.

I have the following struct:

struct b4r_hs {
    char *key, *name, *val;
    UT_hash_handle hh;
};

and the following function:

bool b4r_hs_add(struct b4r_hs **hsl, const char *name, const char *val) {
    struct b4r_hs *hs;
    char *key;
    if (!(key = _B4R_HS_NEW_KEY(name)))
        return false;
    if (!(hs = _b4r_hs_new(key, name, val))) {
        _B4R_FREE(key);
        return false;
    }
    HASH_ADD_STR(*hsl, name, hs);
    return true;
}

However, I've noticed the following warning:

Error after macro substitution: Struct 'UT_hash_handle' doesn't have a field 'hh_prev'

image

but according uthash's User Guide my struct is OK. So, what I'm doing wrong? :-/

(entire code available here)

Edit:

Additional info: I'm using CLion on Xubuntu 16.04 (gcc 5.4 / clang 5.0).

Quuxplusone commented 6 years ago

Is this still a problem for you? I don't see any errors when compiling your source file.

git clone --recursive https://github.com/brook-dev/brook4rest
cd brook4rest/src
git checkout f675dbbe4ccfe07d9e075faba991a8050b1bc7d2
clang b4r_hs.c -I ../include/ -I ../uthash/include/ '-D__nonnull(x)=' '-D__malloc=' -c
Quuxplusone commented 6 years ago

Feel free to reopen this issue if it's still unresolved.

silvioprog commented 6 years ago

Hi @Quuxplusone , thanks for replying. After your answer I've tried purely gcc/clang, but I can't reproduce it too. I don't know how CLion reports this warnings (and how to fix them), but I'm still trying to find it, however, without success. :disappointed:

silvioprog commented 6 years ago

I sent a message to the JetBrains' team. Let's wait for an answer from them. :-)

silvioprog commented 6 years ago

Hello again @Quuxplusone . A JetBrains developer answered me with the following link:

https://youtrack.jetbrains.com/issue/CPP-11419

So it seems a problem related to CLion. :+1: