Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
How to get type define location when reading code/at compile time/at runtime? #1202
I have following code (h.zig):
Then I got:
So How Do I know where the type of stdout_file is defined and where the type of file2 is defined since the both named File?
I think zig do not do this stuff good. You can use const to assign type mulit times. And this will make the reader crazy.
Here is the path to get the define location of the type of stdout_file:
After those 10 steps I finally find the define of the type File.
Base on that the @typename can return same string to different types. I think I can not get type define location at compile time/at runtime to help me print a helpful debug information.
Of cause, One way to solve this problem is try to make the type name globally unique like
The zig std library is following a good rule about the type define file path and the code to include the type. But the careless/bad programmers always exist. If the compiler do not have some rules about the file path and the code to include them, the careless/bad programmers will make the project will difficult to read.
Since zig have a zen that
referenced this issue
Jul 6, 2018
After the above commit:
Now it tells you where structs are defined.