This topic is now archived and is closed to further replies.

constant char warning.

This topic is 4949 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m assigning an ascii value to a char, but I get an annoying, albeit understandable warning. const char Maze::OUTPUT_PATH = 255; Maze.cpp(4) : warning C4305: ''initializing'' : truncation from ''const int'' to ''const char'' How could I get rid of that, safe of ignoring it ?

Share this post

Link to post
Share on other sites
Original post by xMcBaiNx
Heh.. that did it. The logic of this baffles me tough.

Your compiler treats char as signed. A signed char has the range -128 to 127. The compiler is warning you that the number you are assigning (255) is outside of that range. You could also assign -1 instead of 255 to make the compiler happy.

John Bolton
Page 44 Studios
Current project: NHL Faceoff 2005 PS2

Share this post

Link to post
Share on other sites