Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Non-existent semantic errors (after index rebuild and such)

Hey guys,

Remember a while back I wanted to work on (or have done) syntax highlighting for grammars (specifically Flex and Bison) and by doing it build the ground work for any utilities that mix C(++) and some other way of defining things at compile time?

I started doing that and as first things first I started creating my control, a project which Eclipse either didn't like or ignored files of and to go from there.

I didn't get that far, Eclipse CDT is making up non-existent semantic errors.

Prototype:

    static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );

Implementation:

    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)

{

(...)

Line with error:

    yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);

Error:
Invalid arguments '
Candidates are:
void yy_init_buffer(yy_buffer_state *, _IO_FILE *, void *)
'

Typedefs and macros at play:

YY_BUFFER_STATE is a yy_buffer_state* - CDT recognises this when I mouse over.

YY_CURRENT_BUFFER is a macro that gets the current YY_BUFFER_STATE from a stack (array) of them, stored in yy_guts, which mousing over shows it's happy with.

FILE is a typedef of _IO_FILE, Eclipse sees this again

yyscan_t is a typedef of a void* (usually (read: to the best of my knowledge) a pointer to yy_guts)

This is a reentrant scanner for those trying to re-create it. Nothing to do either with the actual lexing part, so to re-create:

%option reentrant
%%

Is all you need for the grammar. I had the extra option with noyywrap but I've just test this, the error persists without (I knew this, for those thinking "why, that wouldn't have made a difference" - I just want you guys to know empirically that the error carries on)

Lastly:
Note that the compiler is fine, -Wall and -Wextra as everyone should (GCC 4.9 from last week) - it gives unused function warnings but no errors. CDT correctly marks the warnings with the yellow warning markers.

I am compiling with --std=c++11, this is not causing the problem though.

I also include <stdio.h> but (again not surprisingly) with or without the problem persists.

So you can see this is not a Flex thing, CDT is somehow not recognising the types, even though it does... which is weird. This is not a using Flex problem either, everything compiles and runs, I am not stuck - this is about fabricating semantic errors. It ought not be specific to flex.

(there are 3 errors it picks up, this details one, all 3 are not actually errors - I've created text-code that even uses the functions these 'error' functions have call-sites in just in case that'd change anything, I've rebuilt the index and rescanned, I've restarted the workspace....

Eclipse 4.2 with the latest CDT that can be installed from the default update site.

Alec

Back to the top