Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error: unknown type name 'yyscan_t' #5

Closed
christopher-hopper opened this issue Oct 6, 2016 · 5 comments
Closed

Compile error: unknown type name 'yyscan_t' #5

christopher-hopper opened this issue Oct 6, 2016 · 5 comments

Comments

@christopher-hopper
Copy link
Contributor

I'm trying to compile and install jsonval and get this error repeated twice:

error: unknown type name ‘yyscan_t’

Complete output:

# make
bison json_parser.y
flex json_scanner.l
gcc -Wall main.c json_parser.tab.c json_scanner.yy.c -o jsonval
In file included from main.c:23:0:
json_parser.tab.h:65:14: error: unknown type name ‘yyscan_t’
 int yyparse (yyscan_t scanner);
              ^
In file included from json_parser.y:21:0:
json_parser.tab.h:65:14: error: unknown type name ‘yyscan_t’
 int yyparse (yyscan_t scanner);
              ^
json_scanner.yy.c:1295:16: warning: ‘input’ defined but not used [-Wunused-function]
     static int input  (yyscan_t yyscanner)
                ^
Makefile:4: recipe for target 'all' failed
make: *** [all] Error 1

Here's my environment details:

# flex --version
flex 2.6.0

# gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609

# uname -a
Linux ThinkPad-Ubuntu 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Can you provide any guidance? Perhaps some documentation on compile requirements would help.

@christopher-hopper
Copy link
Contributor Author

I read some posts describing a workaround for this issue. Apparently the bison parser doesn't know what yyscan_t is, so defining it to void can workaround this.

Here's a diff of a change I made to get the compile working:

diff --git a/json_parser.y b/json_parser.y
index 1f78ef4..9029a10 100644
--- a/json_parser.y
+++ b/json_parser.y
@@ -27,8 +27,8 @@ extern void yyerror(yyscan_t, const char *);
 %defines
 %error-verbose
 %pure-parser
-%parse-param {yyscan_t scanner}
-%lex-param {yyscan_t scanner}
+%parse-param {void *scanner}
+%lex-param {void *scanner}

 %token TSTRING
 %token TNUMBER

christopher-hopper added a commit to christopher-hopper/jsonval that referenced this issue Oct 6, 2016
dangerousben pushed a commit that referenced this issue Aug 19, 2017
@naushada
Copy link

naushada commented Mar 7, 2019

This circular dependency can also be fixed by adding below code in parser.y file
%code requires {
typedef void *yyscan_t;
}

@christopher-hopper
Copy link
Contributor Author

@naushada
Can you supply a pull request with a working fix?

@naushada
Copy link

naushada commented Mar 7, 2019 via email

@naushada
Copy link

naushada commented Mar 7, 2019

clone this link
https://github.com/naushada/jsonParser.git

Please look at parser.y file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants