zeek / spicy

C++ parser generator for dissecting protocols & files.
https://docs.zeek.org/projects/spicy
Other
243 stars 37 forks source link

Generated prototype namespaces do not agree with generated definition namespaces #1752

Closed Kardbord closed 2 months ago

Kardbord commented 2 months ago

spicyc v1.10.1

I've been following along with the Custom Host Applications example from the docs, and noticed that spicyc -P no longer accepts does not accept a prefix the way spicyc -x does. This causes the prototype namespaces and definition namespaces to no longer agree, and therefore the application will fail to build.

For example, following the along with the docs (removing the prefix from the spicyc -P command) produces a header file with __hlt::MyHTTP and hlt::MyHTTP namespaces, and a source file with __hlt_my_http::MyHTTP and hlt_my_http::MyHTTP namespaces. Even if you provide ./ as the prefix to spicyc -x, you end up with __hlt_ and hlt_ in the source files.

The issue can almost be worked around by using spicyc -o ... -c ... instead of spicyc -x, but I still get linker errors about undefined references which I haven't chased down yet.

bbannier commented 2 months ago

In RTD the latest docs refer to the current development head, not the lastest release. The treatment of -x and -P has changed since the last release, so the docs you looked at did not match the version of Spicy you were using; instead you probably want this.

I am closing this, but feel free to reopen or create a new issue if you find anything amiss.

Kardbord commented 2 months ago

Thanks for pointing me to the correct doc version, my mistake there. Following the example for v1.10.1 works as expected when using -g -c and -g -l to generate the source and linker glue separately.

The issue I described does reappear if you deviate from the example and try to use -g -x to generate the source and linker glue in one go, but generating them separately gets me unblocked. Thanks for your help!