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

Unsafe macro in cfe_version.h #845

Closed
skliper opened this issue Aug 26, 2020 · 3 comments
Closed

Unsafe macro in cfe_version.h #845

skliper opened this issue Aug 26, 2020 · 3 comments
Labels

Comments

@skliper
Copy link
Contributor

skliper commented Aug 26, 2020

Is your feature request related to a problem? Please describe.
Unsafe macro (violates coding standard)

#define CFE_STR_HELPER(x) #x /*!< @brief Helper function to concatenate strings from integer macros */

Describe the solution you'd like
Add parentheses

Describe alternatives you've considered
None

Additional context
None

Requester Info
Jacob Hageman - NASA/GSFC

@skliper
Copy link
Contributor Author

skliper commented Aug 26, 2020

Nevermind. Read up on it, since it quotes it's safe.

@astrogeco
Copy link
Contributor

Nevermind. Read up on it, since it quotes it's safe.

Can you add the stuff you read so we can reference it if it comes up again? I was actually discussing this earlier and wondering if we need to have the integer macros at all. If they're all strings then we wouldn't need the helper functions.

@skliper
Copy link
Contributor Author

skliper commented Aug 26, 2020

My preference is to remove any unused macros! I just brushed up on the preprocessor macro at https://www.cprogramming.com/reference/preprocessor/stringizing-operator.html, and wrote a quick test program to try and break it and I couldn't (just to confirm it behaved as expected on random strings).

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

2 participants