gpt4 book ai didi

c - Bison 中奇怪的 C 代码 (yyerror)

转载 作者:太空狗 更新时间:2023-10-29 14:51:01 24 4
gpt4 key购买 nike

我正在使用 Bison 创建一个简单的解析器,但在理解下面的 C 代码时遇到了一些困难。对我来说,它看起来不像是一个有效的语句,但 gcc 巧妙地编译了它并且 block 中的代码在解析错误时执行。

我真的很想知道这到底意味着什么。

我引用的代码来自http://dinosaur.compilertools.net/bison/bison_7.html#SEC66 :

yyerror (s) 
char *s;
{
// Some code here
}

最佳答案

那是 K&R C

在现代 C(C89/90 或 C99)中将是:

int yyerror(char *s)
{
}

关于c - Bison 中奇怪的 C 代码 (yyerror),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8402039/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com