Hello folks. While not a complete beginner in C, I still don't understand what causes the warning described below. Here's the relevant piece of code (from the lemon parser generator, part of sqlite):
And the way I'm using its return value:Code:void *ParseAlloc(void *(*mallocProc)(size_t)){ yyParser *pParser; pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); if( pParser ){ pParser->yyidx = -1; #ifdef YYTRACKMAXSTACKDEPTH pParser->yyidxMax = 0; #endif #if YYSTACKDEPTH<=0 yyGrowStack(pParser); #endif } return pParser; }
Yet it complains about the line which calls ParseAlloc():Code:AST_node* parse_language(scanner_state *state) { AST_node *r; token_value *token; void *pParser; int scanner_state; size_t lexem_len=0; r = ast_malloc_node(top,none,root); if(!r) { return NULL; } pParser = ParseAlloc(malloc); if(!pParser) { free(r); return NULL; } while((scanner_state = scan(state,&token)) > 0) { lexem_len++; printf("OP: %d token: %d\n",scanner_state,token->i); Parse(pParser,scanner_state,token,r); } ParseFree(pParser,free); printf("number of lexems: %d\n",lexem_len); return r; }
So, since I know what I'm doing, and lemon says a parser should be an opaque type and I shouldn't rely on its current implementation, the first thing I do is to make it shut up by casting the retval of the function to (void*) (even if ParseAlloc() returns a void pointer, I know), yet it still complains:warning: assignment makes pointer from integer without a cast
DIFFERENT SIZE?warning: cast to pointer from integer of different size
This drives me crazy, I don't understand where the #&*? it gets this from?
I'm using gcc with --version:
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/usr --enable-shared --enable-languages=c,c++,fortran,objc,obj-c++,treelang --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-__cxa_atexit --disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu --disable-libstdcxx-pch --with-tune=generic
Thread model: posix
gcc version 4.3.2 (GCC)



LinkBack URL
About LinkBacks




