I am new to zig, but am hoping to use it to consume a yacc generated parser. I'm using the very simple hoc1 language from Pike & Kernighan's "UNIX Programming Environment". Instead of the parser printing out the result, I have modified to assign the result to a global variable.
The grammar file is here: https://gist.github.com/cdcarter/cb64f5b28482f28c904119f9694d93f0#file-hoc-y
this results in the following hoc.tab.h header: https://gist.github.com/cdcarter/cb64f5b28482f28c904119f9694d93f0#file-hoc-tab-h
which I translated into zig with zig translate-c: https://gist.github.com/cdcarter/cb64f5b28482f28c904119f9694d93f0#file-hoc-zig
I then use those symbols in my main.zig: https://gist.github.com/cdcarter/cb64f5b28482f28c904119f9694d93f0#file-main-zig
finally, I build this all and used "addCSourceFile" to include the actual parser implementation: https://gist.github.com/cdcarter/cb64f5b28482f28c904119f9694d93f0#file-hoc-tab-c
This results in:
% zig build
MachO Flush... error(link): symbol '_result' defined multiple times
error(link): first definition in '/Users/cdcarter/hoc/zighoc/zig-cache/o/e854fcc73548dd9fd6af4076f010bf6c/hoc.tab.o'
error(link): next definition in '/Users/cdcarter/hoc/zighoc/zig-cache/o/c63d0ae58538b1896e72d0d704793ff4/zighoc.o'
error: MultipleSymbolDefinitions
error: zighoc...
I know I'm not doing anything too complicated, but I'm not sure where to turn next to debug this. hoc.tab.c, the C source for the parser, does not define result, its defined in the header file that I dutifully translated to zig.
I assume my mental model of importing from C is broken, but I can't figure this one out. Any advice would be appreciated!