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

VS2015 warnings #41

Closed
jry2 opened this issue Jun 12, 2015 · 5 comments
Closed

VS2015 warnings #41

jry2 opened this issue Jun 12, 2015 · 5 comments

Comments

@jry2
Copy link
Contributor

jry2 commented Jun 12, 2015

I'm getting following warnings when compiling Nano SVG with VS 2015 RC. I will prepare PR with fixes, unfortunately I'm not able to test Xcode, only VC2015 and GCC. Note: I used premake5.exe vs2015 to make projects, it works fine.

1>------ Rebuild All started: Project: example2, Configuration: Debug Win32 ------
1>  example2.c
1>e:\source\nanosvg\example\stb_image_write.h(156): 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.
1>  c:\program files (x86)\windows kits\10\include\10.0.10056.0\ucrt\stdio.h(205): note: see declaration of 'fopen'
1>e:\source\nanosvg\example\stb_image_write.h(348): warning C4456: declaration of 'i' hides previous local declaration
1>  e:\source\nanosvg\example\stb_image_write.h(271): note: see declaration of 'i'
1>e:\source\nanosvg\example\stb_image_write.h(349): warning C4456: declaration of 'j' hides previous local declaration
1>  e:\source\nanosvg\example\stb_image_write.h(271): note: see declaration of 'j'
1>e:\source\nanosvg\example\stb_image_write.h(495): 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.
1>  c:\program files (x86)\windows kits\10\include\10.0.10056.0\ucrt\stdio.h(205): note: see declaration of 'fopen'
1>e:\source\nanosvg\src\nanosvg.h(120): warning C4201: nonstandard extension used: nameless struct/union
1>e:\source\nanosvg\src\nanosvg.h(359): warning C4201: nonstandard extension used: nameless struct/union
1>e:\source\nanosvg\src\nanosvg.h(730): warning C4127: conditional expression is constant
1>e:\source\nanosvg\src\nanosvg.h(2487): warning C4127: conditional expression is constant
1>e:\source\nanosvg\src\nanosvg.h(2488): warning C4127: conditional expression is constant
1>e:\source\nanosvg\src\nanosvgrast.h(251): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(632): warning C4456: declaration of 's' hides previous local declaration
1>  e:\source\nanosvg\src\nanosvgrast.h(577): note: see declaration of 's'
1>e:\source\nanosvg\src\nanosvgrast.h(753): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(755): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(756): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(849): warning C4244: 'function': conversion from 'int' to 'unsigned char', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(844): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(859): warning C4244: 'function': conversion from 'int' to 'unsigned char', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(854): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(1093): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(1094): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(1095): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(1132): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(1133): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(1134): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(1174): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(1175): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(1185): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(1186): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
1>e:\source\nanosvg\example\example2.c(43): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
1>e:\source\nanosvg\example\example2.c(44): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
1>e:\source\nanosvg\src\nanosvgrast.h(1198): warning C4701: potentially uninitialized local variable 'cb' used
1>e:\source\nanosvg\src\nanosvgrast.h(708): warning C4701: potentially uninitialized local variable 'right' used
1>e:\source\nanosvg\src\nanosvgrast.h(707): warning C4701: potentially uninitialized local variable 'left' used
1>e:\source\nanosvg\src\nanosvgrast.h(707): warning C4701: potentially uninitialized local variable 'firstLeft' used
1>e:\source\nanosvg\src\nanosvgrast.h(708): warning C4701: potentially uninitialized local variable 'firstRight' used
1>e:\source\nanosvg\src\nanosvgrast.h(435): warning C4701: potentially uninitialized local variable 'prevy' used
1>e:\source\nanosvg\src\nanosvgrast.h(435): warning C4701: potentially uninitialized local variable 'prevx' used
1>e:\source\nanosvg\src\nanosvgrast.h(448): warning C4701: potentially uninitialized local variable 'lx' used
1>e:\source\nanosvg\src\nanosvgrast.h(448): warning C4701: potentially uninitialized local variable 'ly' used
1>e:\source\nanosvg\src\nanosvgrast.h(449): warning C4701: potentially uninitialized local variable 'rx' used
1>e:\source\nanosvg\src\nanosvgrast.h(449): warning C4701: potentially uninitialized local variable 'ry' used
1>  example2.vcxproj -> E:\Source\nanosvg\build\.\example2.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
@memononen
Copy link
Owner

The warnings about nanosvg/rast.h looks sane things to fix.

I really really really hate the warnings about NSVG_NOTUSED. A new compiler, and we're back to square one again, and again.

If upstream stb_image_write fixes the warnings, let's update, else just leave it as is.

Thanks for taking the time to improve the code!

@jry2
Copy link
Contributor Author

jry2 commented Jun 12, 2015

Could you please check this version in Xcode? It compiles without warnigs with GCC 4.7.2 and VC2015 RC.

#define NSVG_NOTUSED(v) ((void)(v))

@jry2
Copy link
Contributor Author

jry2 commented Jun 12, 2015

Upstream stb_image_write.h is even worse than your version ;-) I will patch only nanosvg.h and nanosvgrast.h warnings.

1>e:\source\nanosvg\example\stb_image_write.h(210): 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.
1>  c:\program files (x86)\windows kits\10\include\10.0.10056.0\ucrt\stdio.h(205): note: see declaration of 'fopen'
1>e:\source\nanosvg\example\stb_image_write.h(329): warning C4457: declaration of 'comp' hides function parameter
1>  e:\source\nanosvg\example\stb_image_write.h(278): note: see declaration of 'comp'
1>e:\source\nanosvg\example\stb_image_write.h(372): 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.
1>  c:\program files (x86)\windows kits\10\include\10.0.10056.0\ucrt\stdio.h(205): note: see declaration of 'fopen'
1>e:\source\nanosvg\example\stb_image_write.h(553): warning C4456: declaration of 'i' hides previous local declaration
1>  e:\source\nanosvg\example\stb_image_write.h(476): note: see declaration of 'i'
1>e:\source\nanosvg\example\stb_image_write.h(554): warning C4456: declaration of 'j' hides previous local declaration
1>  e:\source\nanosvg\example\stb_image_write.h(476): note: see declaration of 'j'
1>e:\source\nanosvg\example\stb_image_write.h(702): 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.

@memononen
Copy link
Owner

I have used that unused macro before, and cannot remember anymore why I changed that. It might have been gcc with tighter warning level.

@jry2
Copy link
Contributor Author

jry2 commented Jun 12, 2015

Some warnings are fixed in #42
I didn't fix following warnings:

1>E:\Source\nanosvg\src\nanosvg.h(120): warning C4201: nonstandard extension used: nameless struct/union
1>E:\Source\nanosvg\src\nanosvg.h(359): warning C4201: nonstandard extension used: nameless struct/union
1>E:\Source\nanosvg\src\nanosvg.h(730): warning C4127: conditional expression is constant
1>E:\Source\nanosvg\src\nanosvg.h(2487): warning C4127: conditional expression is constant
1>E:\Source\nanosvg\src\nanosvg.h(2488): warning C4127: conditional expression is constant

C4201 nonstandard extension used should be probably fixed in VC project, because anonymous structures and unions are valid in C11.
C4127 conditional expression is constant is problematic NSVG_NOTUSED macro.

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