Jump to content
  • Advertisement

Archived

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

Abominus

C Portability Question

This topic is 6030 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

Is the code ''unsigned long foo = 0xFFFF'' portable? Immediate values default to ''int'' right? So on a system which uses 16-bit ints and 32-bit longs, will the compiler treat the literal 0xFFFF as an int and signed extend it to 0xFFFFFFFF before assignment?

Share this post


Link to post
Share on other sites
Advertisement
Nope, it''s not portable and it won''t sign-extend.

however, this will:
unsigned long foo = -1;

This will give you all 1s in any two''s-compliment architecture.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!