mystor / rust-cpp

Embed C++ directly inside your rust code!
Apache License 2.0
795 stars 44 forks source link

Metadata parsing assumes little endian, even for big endian targets #90

Closed aprilwade closed 3 years ago

aprilwade commented 3 years ago

cpp_macros assumes little endian when parsing metadata, even when the target is big endian (for example, powerpc-unknown-linux-gnu). I'd write a PR, but I'm not sure how best to approach solving this. There doesn't seem to be a good way to discover the target from within a proc macro. Maybe it would be better to ensure the metadata is always stored little endian regardless of the platform?

ogoffart commented 3 years ago

I guess one way to do it would be to write something like 0xfeff in the metadata just after the "magic" part, then read it from the read_metadata function and if we read 0xfffe0000, then it means it is big endian and we must read all the number form big endian.

It would be great if you can make a PR.