basic/define-variable #195
Replies: 3 comments 3 replies
-
我在使用zap的时候发现了变量作用域的知识点,在此总结一下以飨读者: 按照C语言的角度看: 全局变量(当前文件全局作用域)全局变量等顶层声明与顺序无关,在编译时求值。 例如zap routes里面的routes、dynamic_counter。 局部变量(函数内部、块内部作用域)函数内部的定义的buf,作用域就只在函数内。 局部变量名不能和全局变量名一致,zig不能用局部变量覆盖全局变量。 暂时总结到这,如教程有可忽略此评论( |
Beta Was this translation helpful? Give feedback.
1 reply
-
看起来 zig 不支持像 C 那样单独声明变量,所以弄出来 undefined 来实现单独声明的效果 |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
basic/define-variable
简单、快速地学习 Zig,ziglang中文教程,zig中文教程
https://course.ziglang.cc/basic/define-variable
Beta Was this translation helpful? Give feedback.
All reactions