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

Improved "misc.c does not need to be compiled" message #643

Merged
merged 2 commits into from
Jan 12, 2024

Conversation

gojimmypi
Copy link
Contributor

As noted in #633, when building with the Espressif ESP-IDF, and the misc.c is not excluded in the CMakeLists.txt, I see this message:

[2/9] Building C object esp-idf/wolfssh/CMakeFiles/__idf_wolfssh.dir/C_/workspace/wolfssh-gojimmypi/src/misc.c.obj
C:/workspace/wolfssh-gojimmypi/src/misc.c:76:10: warning: #warning MISC_WARNING [-Wcpp]
   76 |         #warning MISC_WARNING
      |          ^~~~~~~

In particular, note the MISC_WARNING was previously defined as a descriptive string, but that string is not displayed at compile time.

This PR adds some macro logic to detect if _Pragma is supported, and if so the contents of MISC_WARNING is string-ified and displayed as appropriate.

Although this might have been simplified by simply using the same string in multiple places, there may be value in having the single definition of MISC_WARNING available elsewhere as needed.

Using this change, the warning is manifested like this in my environment:

[2/9] Building C object esp-idf/wolfssh/CMakeFiles/__idf_wolfssh.dir/C_/workspace/wolfssh-gojimmypi/src/misc.c.obj
C:/workspace/wolfssh-gojimmypi/src/misc.c:83:9: note: '#pragma message: misc.c does not need to be compiled when using inline (NO_INLINE not defined))'
   83 |         _Pragma(MISC_TOSTRING(message(MISC_WARNING)))
      |         ^~~~~~~
[3/9] Building C object esp-idf

Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to not just use WOLFSSL_IGNORE_FILE_WARN in your user_settings.h? That option covers several other places too.

@gojimmypi
Copy link
Contributor Author

Any reason to not just use WOLFSSL_IGNORE_FILE_WARN in your user_settings.h? That option covers several other places too.

Yes: my final solution was to exclude the misc.c in the build and not trigger the warning at all. The issue is that when I first saw the "MISC_WARNING" it was not very intuitive. This PR prints the intended message as desired. If there's going to be a warning, it should print the proper text.

@gojimmypi gojimmypi requested a review from dgarske December 29, 2023 21:00
@ejohnstown
Copy link
Contributor

I did the change for the MISC_WARNING string. I don't know why I did it that way, but it should probably go back to just being a string on the #warning directive. I suppose we could switch to using _Pragma, but that's going to be the first one. I don't care about duplicating the string there, it isn't compiled code.

ejohnstown
ejohnstown previously approved these changes Dec 30, 2023
@gojimmypi
Copy link
Contributor Author

I suppose we could switch to using _Pragma, but that's going to be the first one.

I'm ok to go back to the simpler code & duplicate the compile-time text warning. There's otherwise no compelling reason to introduce new things. Just let me know which you prefer.

@gojimmypi
Copy link
Contributor Author

I've reverted the defined MISC_WARNING macro string to the simpler, duplicated text.

@ejohnstown ejohnstown self-requested a review January 11, 2024 23:59
@ejohnstown ejohnstown dismissed dgarske’s stale review January 12, 2024 00:06

It needed to be fixed. This fix undoes a dumb change I had made.

@ejohnstown ejohnstown merged commit debba8b into wolfSSL:master Jan 12, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants