Ploumploum
Ploumploum

Reputation: 333

How to fix GCC type warning on variable returned by the parser generator?

I expect Packcc parser generator "$0s" or "$0e" variables to throw an int in the parser actions, because theses variables represents a position in the input.

I made a minimal parser that prints the position of the last char of the word.

word <- [a-z]+[\n]    {printf("Position %i\n", $0e);}

%%

int main()
{
    pcc_context_t *ctx = pcc_create(NULL);
    while(pcc_parse(ctx, NULL));
    pcc_destroy(ctx);
    return 0;
}

After parser generation using "packcc" command I compile the C generated file then Gcc sends this warning.

warning: type defaults to 'int' in type name [-Wimplicit-int]

Thank you in advance.

Upvotes: 0

Views: 74

Answers (1)

Nate Eldredge
Nate Eldredge

Reputation: 58142

This looks like a bug in that version of the packcc parser generator. It is now fixed in master, so try upgrading.

Or you can simply ignore the warning as the type should indeed be int.

Upvotes: 1

Related Questions