Barret Gaylor
31 posts
I am a game designer who recently became interested in coding in a handmade way. I am not that experienced, but I want to learn.
What am I doing wrong?
I have been trying to use stb_image.h but I am running into some errors that I don't understand. Can some one help me figure it out.

 1 2 3 4 5 6 7 8 9 #define STB_IMAGE_IMPLEMENTATION #include "../../stb/stb_image.h" internal void LoadSTBImage(char *Filename) { } 

These are the errors I got:
f:\stb\stb_image.h(4503): error C2220: warning treated as error - no 'object' file generated
f:\stb\stb_image.h(4503): warning C4244: '=': conversion from 'int' to 'stbi__uint16', possible loss of data
f:\stb\stb_image.h(5082): warning C4244: 'initializing': conversion from 'int' to 'stbi__uint16', possible loss of data
f:\stb\stb_image.h(5089): warning C4244: '=': conversion from 'int' to 'stbi_uc', possible loss of data
f:\stb\stb_image.h(5090): warning C4244: '=': conversion from 'int' to 'stbi_uc', possible loss of data
f:\stb\stb_image.h(5091): warning C4244: '=': conversion from 'int' to 'stbi_uc', possible loss of data
f:\stb\stb_image.h(4503): error C2220: warning treated as error - no 'object' file generated
f:\stb\stb_image.h(4503): warning C4244: '=': conversion from 'int' to 'stbi__uint16', possible loss of data
f:\stb\stb_image.h(5082): warning C4244: 'initializing': conversion from 'int' to 'stbi__uint16', possible loss of data
f:\stb\stb_image.h(5089): warning C4244: '=': conversion from 'int' to 'stbi_uc', possible loss of data
f:\stb\stb_image.h(5090): warning C4244: '=': conversion from 'int' to 'stbi_uc', possible loss of data
f:\stb\stb_image.h(5091): warning C4244: '=': conversion from 'int' to 'stbi_uc', possible loss of data

Any help would be helpful. Thank you.
Aidan
12 posts
What am I doing wrong?
So it looks like you're building with the -W4 (warning level 4) and -WX (treat warnings as errors) flags turned on, and stb_image has a few internal warnings, which then get treated as errors by your compiler. They're simple warnings to fix, so they should probably be cleaned up by Sean at some point. In the mean time, you have a couple of options.

You could drop your warning level down to 3, or stop compiling with warnings as errors (This probably isn't what you want to do)

You can fix the warnings by changing these lines in stb_image.h
  1 2 3 4 5 6 7 8 9 10 11 12 //On line 4503 for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is // ^^ add this //On line 5082 stbi__uint16 px = (stbi__uint16)stbi__get16le(s); // ^^ add this //On lines 5089 to 5091 out[0] = (stbi_uc)((r * 255)/31); out[1] = (stbi_uc)((g * 255)/31); out[2] = (stbi_uc)((b * 255)/31); 
Barret Gaylor
31 posts
I am a game designer who recently became interested in coding in a handmade way. I am not that experienced, but I want to learn.
What am I doing wrong?
Thank you. Its working now.
Dan
22 posts
A man named Dan.
What am I doing wrong?
aidanb
They're simple warnings to fix, so they should probably be cleaned up by Sean at some point. In the mean time, you have a couple of options.

Perhaps you could submit a pull request with your fixes to save Sean the effort?