struct having name like MyData_T_int
#17239
Replies: 5 comments 4 replies
-
Interesting way of hacking the compiler. :-)
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the interesting find! |
Beta Was this translation helpful? Give feedback.
-
In the original V, _ was banned in struct names for this reason. Also nice for the one way rule. I wish I kept this rule. |
Beta Was this translation helpful? Give feedback.
-
How about just banning Edit: it would need to be a ban for |
Beta Was this translation helpful? Give feedback.
-
It's better to know about such hacks, even if inconvenient, than to not know. This way they can be dealt with in some way. |
Beta Was this translation helpful? Give feedback.
-
I purposefully named the struct
MyData_T_int
to see what happens. This fails to run but C code is generated without errors. It seems like the definition ofMyData[int]
is overwritten byMyData_T_int
, so there ends up only one struct definition which causes the error.The code runs if fields of both struct have same name and same type or type is castable(like int to f32).
How should such a problem be solved? I tried searching the internet but didn't find anything. I am not very knowledgeable about compilers and not sure how other languages solve such an issue?
Possible soln that come to my mind 1) not allow such name 2) add some suffix like
MyData_T_int_suffix
3) ignore?Btw, great language, keep up the great work.
Beta Was this translation helpful? Give feedback.
All reactions