HuoLanguage / huo

interpreted language written in C
MIT License
212 stars 21 forks source link

Hash table assert macros cause error #40

Closed incrediblesound closed 8 years ago

incrediblesound commented 8 years ago

I get a bunch of error when I try to make now, but I'm not sure how to fix this one:

src/structures/hash_table.c:43:1: error: pasting formed 'static_assertion_failed_"Hash table expands too much"', an invalid preprocessing token
STATIC_ASSERT(HASH_TABLE_MAX_LOAD_NUM * HASH_TABLE_EXPAND_NUM * HASH_TABLE_MIN_LOAD_DENOM  > HASH_TABLE_MIN_LOAD_NUM * HASH_TABLE_MAX_LOAD_DENOM * HASH_TABLE_EXPAND_DENOM, "Hash table expands too much");
^
src/structures/../base_util.h:16:26: note: expanded from macro 'STATIC_ASSERT'
    typedef struct { int CTASTR(static_assertion_failed_,msg) : !!(cond); } \
                         ^
src/structures/../base_util.h:14:26: note: expanded from macro 'CTASTR'
#define CTASTR(pre,post) CTASTR2(pre,post)
                         ^
src/structures/../base_util.h:13:31: note: expanded from macro 'CTASTR2'
#define CTASTR2(pre,post) pre ## post
                              ^
src/structures/hash_table.c:43:173: error: expected ';' at end of declaration list
STATIC_ASSERT(HASH_TABLE_MAX_LOAD_NUM * HASH_TABLE_EXPAND_NUM * HASH_TABLE_MIN_LOAD_DENOM  > HASH_TABLE_MIN_LOAD_NUM * HASH_TABLE_MAX_LOAD_DENOM * HASH_TABLE_EXPAND_DENOM, "Hash table expands too much");
                                                                                                                                                                            ^
src/structures/../base_util.h:16:58: note: expanded from macro 'STATIC_ASSERT'
    typedef struct { int CTASTR(static_assertion_failed_,msg) : !!(cond); } \
                                                         ^
src/structures/../base_util.h:14:38: note: expanded from macro 'CTASTR'
#define CTASTR(pre,post) CTASTR2(pre,post)
                                     ^
src/structures/../base_util.h:13:34: note: expanded from macro 'CTASTR2'
#define CTASTR2(pre,post) pre ## post
TheLoneWolfling commented 8 years ago

Whoops. I'll take a look at it.

TheLoneWolfling commented 8 years ago

Have you changed HASH_TABLE_MAX_LOAD_NUM, HASH_TABLE_EXPAND_NUM, HASH_TABLE_MIN_LOAD_DENOM, HASH_TABLE_MIN_LOAD_NUM, HASH_TABLE_MAX_LOAD_DENOM, or HASH_TABLE_EXPAND_DENOM?

TheLoneWolfling commented 8 years ago

So what's happening here is that the fallback implementation of static_assert is borked, and for some reason your compiler is falling back to the fallback.

I'll fix the fallback implementation, but I'm intrigued as to why it's falling back in the first place. Are you using GCC? If so, is _Static_assert defined?

TheLoneWolfling commented 8 years ago

Should be fixed by this commit.

incrediblesound commented 8 years ago

I use Clang. I'll look into why _Static_assert might not be defined on my system.