decomp.me
decomp.me copied to clipboard
Show sizeof and offset of struct members when using language server
This would be a great improvement that would reduce guesswork of making sure structs are correctly sized and padded and quickly figuring out what sizeof may be used in code for example when allocating a struct. There are catches tho, compiler specific packing/padding and default packing/padding as well as compiler packing/padding arguments.
For example MSVC usually packs to 4 bytes, but if the struct contains a double it packs to 8. I suppose these nuances could be specified in compiler config and language server would need to be aware of what compiler args for packing are being used?
This isn't reliable as part of the language server, since the language server is always clangd, and thus won't be able to exactly replicate e.g. MSVC. Unless we can solve that problem, this isn't feasible.
maybe there's a way to tell the language server the sizes of primitives
@nanaian clang has an MSVC-compatible frontend (in the form of clang-cl), so it should be possible to set it up to mostly work. (I say mostly because clang-cl has a few minor rough edges with the alignment of some exotic primitives like AVX stuff, but it shouldn't impact the vast majority of uses).