Jump to content
  • Advertisement

Archived

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

jfclavette

constant char warning.

This topic is 5164 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
Advertisement
Yeah, I didn''t want to resort to casting, surely there''s something like 1.0f for chars ? no ? Guess I''ll use a cast then.

Share this post


Link to post
Share on other sites
You can always use hexidecimal or octal escaped character literals. Ex:

const char x = ''\xff'';

Share this post


Link to post
Share on other sites
quote:
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!