nedpals / tree-sitter-v

Tree-sitter parser for V
MIT License
24 stars 5 forks source link

add #include "tree_sitter/parser.h" so C sees the proper definition for tree_sitter_v too #2

Closed spytheman closed 3 years ago

spytheman commented 3 years ago

Previously, since tree_sitter_v was not declared on the C side (it is only when the .c file is compiled, but was missing in the V wrapper), the C compiler just assumed it returns an int and casted the pointer to an int, which works for small pointers < 2^32 , but only incidentally.

Now, by including tree_sitter/parser.h in the V wrapper too (through bindings.h), and declaring the exact signature of that function, the C compiler knows that function returns a pointer instead (i.e. potentially a 64bit value > 2^32), so it does not cast it.