HASH_ADD_STR compile error on Linux

99 views
Skip to first unread message

Shawn Firth

unread,
Oct 20, 2016, 6:05:39 PM10/20/16
to uthash
I am new to uthash, but not new to C or C++.

I am trying to use uthash inside some old, existing C code, but I am getting some very ugly compiler errors on RHEL 7.2 x64. The uthash tests compiled and ran without any errors.

Any help would be appreciated.

Thanks...


Here is my structure:

typedef struct xmlNodeData
{
char pe[32]; // uthash activityHash string key
char se[32];
...
UT_hash_handle hh; // Makes this a uthash collection
} xmlNodeData;

Here is the line of code blowing up:
{
...
    xmlNodeData* activityHash; // pointer to uthash collection

    xmlNodeData* curNode; // pointer to newly allocated, and populated structure

...
    HASH_ADD_STR(activityHash, pe, curNode->pe);
...
}

Here is the compiler error I'm getting:

In file included from /home/sfirth/JCAT2020/include/crw.h:29:0,
                 from crwDataToXML.c:30:
/home/sfirth/JCAT2020/include/uthash/uthash.h:318:36: error: request for member 'pe' in something not a structure or union
   HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add)
                                    ^
/home/sfirth/JCAT2020/include/uthash/uthash.h:542:55: note: in definition of macro 'HASH_JEN'
   unsigned const char *_hj_key=(unsigned const char*)(key);                      \
                                                       ^
/home/sfirth/JCAT2020/include/uthash/uthash.h:310:3: note: in expansion of macro 'HASH_VALUE'
   HASH_VALUE(keyptr, keylen_in, _ha_hashv);                                      \
   ^
/home/sfirth/JCAT2020/include/uthash/uthash.h:318:3: note: in expansion of macro 'HASH_ADD_KEYPTR'
   HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add)
   ^
/home/sfirth/JCAT2020/include/uthash/uthash.h:377:5: note: in expansion of macro 'HASH_ADD'
     HASH_ADD(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add)
     ^
crwDataToXML.c:1016:3: note: in expansion of macro 'HASH_ADD_STR'
   HASH_ADD_STR(activityHash, pe, curNode->pe);

Shawn Firth

unread,
Oct 21, 2016, 10:16:19 AM10/21/16
to uthash
Please ignore.
I had a typo in my code.
Compiling and running like a champ now!
Reply all
Reply to author
Forward
0 new messages