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

MSVC: Add compiler printf validation #3028

Merged
merged 1 commit into from Jun 2, 2021
Merged

Conversation

@SupSuper
Copy link
Contributor

@SupSuper SupSuper commented May 28, 2021

Currently ScummVM uses the GCC_PRINTF annotation to validate strings in printf-like functions. This doesn't work for MSVC which has a different annotation for this, so I added it, and corrected some incorrect usages.

Sadly MSVC requires annotating the parameter, not the function, so I couldn't combine both macros into one.

@SupSuper SupSuper force-pushed the SupSuper:msvc-printf branch from de797b1 to 29c4ca1 May 28, 2021
@bluegr
Copy link
Member

@bluegr bluegr commented Jun 2, 2021

Thanks for this. Indeed, this is the recommended way to mark such parameters in MSVC:
https://docs.microsoft.com/en-us/cpp/code-quality/annotating-function-parameters-and-return-values?view=msvc-160

This will help identify incorrect usage of printf and will aid in development.

Thanks!

@bluegr bluegr merged commit e3d082d into scummvm:master Jun 2, 2021
2 checks passed
2 checks passed
@codacy-production
Codacy Static Code Analysis Codacy Static Code Analysis
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@digitall
Copy link
Member

@digitall digitall commented Jun 3, 2021

@SupSuper @bluegr ... Looks like this broke builds on the NDS toolchain. The error is "error: attributes are not allowed on a function-definition" ... but not sure why that happens there and not on other POSIX type builds:
https://buildbot.scummvm.org/#/builders/87/builds/1007

@SupSuper
Copy link
Contributor Author

@SupSuper SupSuper commented Jun 3, 2021

@digitall Nice catch, seems to be a bug with old GCC versions, should be fixed now.

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