Skip to content

avoid C4996 warning on MSVC for utilities#142

Merged
rouault merged 5 commits into
OSGeo:masterfrom
jmckenna:C4996-warning
Mar 13, 2026
Merged

avoid C4996 warning on MSVC for utilities#142
rouault merged 5 commits into
OSGeo:masterfrom
jmckenna:C4996-warning

Conversation

@jmckenna
Copy link
Copy Markdown
Contributor

@jmckenna jmckenna commented Mar 13, 2026

  • using master with MSVC 2022 gives the following warnings:
[ 71%] Building C object bin/CMakeFiles/listgeo.dir/listgeo.c.obj
listgeo.c
\libgeotiff\bin\listgeo.c(280): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
\libgeotiff\bin\listgeo.c(286): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
\libgeotiff\bin\listgeo.c(274): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
[ 75%] Building C object bin/CMakeFiles/listgeo.dir/getopt.c.obj
getopt.c
[ 78%] Linking C executable listgeo.exe
[ 78%] Built target listgeo
[ 82%] Building C object bin/CMakeFiles/applygeo.dir/applygeo.c.obj
applygeo.c
[ 85%] Building C object bin/CMakeFiles/applygeo.dir/getopt.c.obj
getopt.c
[ 89%] Linking C executable applygeo.exe
[ 89%] Built target applygeo
[ 92%] Building C object bin/CMakeFiles/geotifcp.dir/geotifcp.c.obj
geotifcp.c
\libgeotiff\bin\geotifcp.c(252): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
\libgeotiff\bin\geotifcp.c(253): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
\libgeotiff\bin\geotifcp.c(254): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
\libgeotiff\bin\geotifcp.c(255): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
\libgeotiff\bin\geotifcp.c(256): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
\libgeotiff\bin\geotifcp.c(257): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
\libgeotiff\bin\geotifcp.c(317): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
\libgeotiff\bin\geotifcp.c(484): warning C4996: 'setbuf': This function or variable may be unsafe. Consider using setvbuf instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
[ 96%] Building C object bin/CMakeFiles/geotifcp.dir/getopt.c.obj
getopt.c
[100%] Linking C executable geotifcp.exe
[100%] Built target geotifcp
  • this PR sets -D_CRT_SECURE_NO_WARNINGS in the /bin CMakeLists.txt (which is already set in the root CMakeLists.txt)

Comment thread libgeotiff/bin/CMakeLists.txt Outdated
@jmckenna jmckenna changed the title avoid C4996 warning on MSVC avoid C4996 warning on MSVC for utilities Mar 13, 2026
Co-authored-by: Even Rouault <even.rouault@spatialys.com>
Comment thread libgeotiff/bin/CMakeLists.txt
Comment thread libgeotiff/bin/CMakeLists.txt Outdated
jmckenna and others added 3 commits March 13, 2026 13:28
Co-authored-by: Even Rouault <even.rouault@spatialys.com>
Comment thread libgeotiff/bin/CMakeLists.txt
@rouault rouault merged commit ffafade into OSGeo:master Mar 13, 2026
6 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.

2 participants