Skip to content

Conversation

generalmimon
Copy link
Member

It's tested under Windows 10 64-bit with the g++ compiler 8.3.0. It worked, but I had to get endian.h and byteswap.h from the internet, because they're not available on Windows and the C++ runtime relies on them. Maybe the runtime should be fixed to support Windows out-of-the-box as well.

@generalmimon generalmimon requested a review from GreyCat April 25, 2020 09:18
@generalmimon
Copy link
Member Author

generalmimon commented Apr 25, 2020

And one thing: I noticed that all usage examples for C++ (in C++ notes and format gallery) use syntax gif_t data(&ks) for instantiation, and not creating a pointer like gif_t* data = new gif_t(&ks). This works, but it implies non-intuitive syntax when it comes to reference the substructures of the generated parser. In this example, it would look like this:

gif_t g(&ks);
std::cout << "width = " << g.logical_screen()->image_width() << std::endl;
std::cout << "height = " << g.logical_screen()->image_height() << std::endl;

As you can see, when referencing data.logical_screen.image_width member, it's necessary to first use the dot . and then ->, because the generated code by KSC always uses pointers. So I opted to use them as well while instantiating the gif_t here, because the -> -> variant is much better. And I think all usage examples in the documentation and formats gallery should work this way as well.

@GreyCat
Copy link
Member

GreyCat commented Apr 25, 2020

Broadly, the idea was actually to remove this piece of quick start documentation here and have it completely in one place: https://kaitai.io/ — with interactive language switch.

On topic of C++: your current implantation leaks memory, having new without relevant delete. You either need to call that manually, or use smart pointers.

@generalmimon
Copy link
Member Author

@GreyCat OK, thanks for your response, I'm closing this then. It's just that GitHub kaitai_struct repo homepage might be a possible entry point for the newcomers, and the README seems unfinished.

So the examples in this README should be deleted completely and link to the https://kaitai.io/ instead?

@GreyCat
Copy link
Member

GreyCat commented Apr 25, 2020

Yeah, I believe we wanted to do it 2-3 years ago, but never got to actually proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants