-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add struct name for typedef struct in cFE #769
Comments
surprised any tools in use today don't understand the "typedef struct {} foo_t;" form. But not difficult to add. I suggest a ticket also be filed against github.com/nasa/osal and github.com/nasa/psp ? |
In general I agree that it can be beneficial to also give the struct a name in addition to the typedef. But the struct name should not end in |
I vote for |
I'd like to take this on, but I'd like concurrence on naming. I am ok with no suffix at all, but would prefer:
|
I still vote for no suffix - it is easier to read and I don't see what value the suffix adds here. Whenever these names are referenced it must already be preceded by a Typedefs OTOH appear "bare" in code (no keyword) so an |
Fix #769, Adds name to struct/union/enum typedefs
Late to the party, but just an interesting and subtle note on something I recently ran across related to this item and differences between C and C++ (I know cFE/cFS is C). The following is valid C code, but not valid C++ code: struct foo{}; The reason being (if I understand correctly... I didn't totally go back to the C and C++ standards) that in C, the named structs and the typedefs are kept separately... whereas in C++, a struct is basically a class and C++ removed the need to say "class foo" or "struct foo" when declaring variables/parameters, etc., so the typedefs and the structs/classes all end up in the same name space. Now I admit, the example code is very evil and I never want to see anyone do anything like it... but it does point out that you need to be careful about names of typedefs and names of structs/classes and their potential for collision. In the end, I might make a case that a tool that does not understand anonymous structs with typedef names is not doing things correctly (although I don't know if pahole can necessarily tell if binary code came from a C or C++ compiler)... food for thought. |
nom nom food for thought... I think we're ok, all of our typedefs are of the form: So little/no collision risk and if there ever is a collision, that's on us. |
Is your feature request related to a problem? Please describe.
All of the struct used in
cFE
are declared withtypedef struct {} TYPEDEF_NAME
, which make the struct anonymous in debug info, and make it harder to access from the debugging tools such as `pahole:Expect to be like:
Describe the solution you'd like
Add struct name to all the typedef struct in cFE, for example:
From:
Changed to:
Describe alternatives you've considered
Additional context
Requester Info
@mlouielu
The text was updated successfully, but these errors were encountered: