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

Using snprintf instead of sprintf for filenames #108

Open
jwreep opened this issue Oct 18, 2024 · 2 comments
Open

Using snprintf instead of sprintf for filenames #108

jwreep opened this issue Oct 18, 2024 · 2 comments

Comments

@jwreep
Copy link
Member

jwreep commented Oct 18, 2024

This is relatively minor, but it clutters the compiler output. Recent C++ versions are now returning warnings for sprintf, which can lead to memory leaks, and recommend using snprintf instead. As a result, when compiling HYDRAD, there are lots of warnings like this:

WARNING: ../source/mesh.cpp:1866:1: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  
Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. 
[-Wdeprecated-declarations]
sprintf( szPhysicalFilename, "Results/profile%i.phy", iFileNumber );

The code doesn't have any memory leaks from what I can tell, but it would be nice to clear away these warnings at some point.

@sjbradshaw
Copy link
Contributor

sjbradshaw commented Oct 19, 2024 via email

@jwreep
Copy link
Member Author

jwreep commented Oct 21, 2024

I'm currently using g++ 13.2.0. The same warnings appear for slightly older versions as well.

Yes, we could certainly just use a compiler switch to ignore the warnings.

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

No branches or pull requests

2 participants