Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show sizeof and offset of struct members when using language server #867

Open
tomsons26 opened this issue Sep 24, 2023 · 3 comments
Open
Labels

Comments

@tomsons26
Copy link

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?

@bates64
Copy link
Member

bates64 commented Sep 25, 2023

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.

@ethteck
Copy link
Member

ethteck commented Sep 25, 2023

maybe there's a way to tell the language server the sizes of primitives

@roblabla
Copy link
Contributor

roblabla commented Sep 25, 2023

@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).

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

No branches or pull requests

4 participants