'Getting byte size of a c++ struct given as a string
I have the following problem. I am given a string. This string represents is a valid c++ struct.
I need to figure out the fastest way to get the size in bytes of this struct.
The most obvious approach to me is:
Write struct to a file and turn that file into a script that writes the size to a file, call a compiler from the system, compile the file, run the executable, parse the file.
This is absurd, there has to be a better way.
I have heard about GCC's JITC library, that might be a better approach. But since I don;t need full blown compilation there might be a simpler way?
The struct is represented as it would in native c++ code, i.e. I have this string
"struct MySstruct { int field1; void* field2; short field3; };"
Would be the content of the string.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
