小编Shi*_*lCh的帖子

这有什么样的功能?

我正在阅读"C编译器设计"一书.在基础部分,我发现lexer的ac片段是这样的 -

static int Lookahead = -1;
int match(token)
int token;
{
 if(Lookahead == -1)
    Lookahead = lex();

 return token == Lookahead;
}

void advance(){
   Lookahead = lex();
}
Run Code Online (Sandbox Code Playgroud)

我对如何在gnu gcc上编译匹配函数感到困惑.所以我写了一个看起来像的函数

int a(token)
int token;
{
 printf("Value of token is %d", token);
}
int main()
{
 printf("Hello world!\n");
 a(1);
 return 0;
}
Run Code Online (Sandbox Code Playgroud)

我得到以下输出 -

你好,世界!令牌的值为1

但我没有得到功能声明背后的原因.以这种方式声明功能有什么好处?而令牌的价值如何为1?为什么它不是编译错误?它是C中的某种函数声明吗?

谢谢你查看我的问题.任何形式的帮助都会很棒.

c function construct

3
推荐指数
1
解决办法
132
查看次数

标签 统计

c ×1

construct ×1

function ×1