home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 241,346 of 243,242   
   pozz to All   
   signed vs unsigned and gcc -Wsign-conver   
   20 Oct 25 17:03:58   
   
   From: pozzugno@gmail.com   
      
   After many years programming in C language, I'm always unsure if it is   
   safer to use signed int or unsigned int.   
      
   Of course there are situations where signed or unsigned is clearly   
   better. For example, if the values could assume negative values, signed   
   int is the only solution. If you are manipulating single bits (&, |, ^,   
   <<, >>), unsigned ints are your friends.   
      
   What about other situations? For example, what do you use for the "i"   
   loop variable?   
      
   I recently activated gcc -Wsign-conversion option on a codebase and   
   received a lot of warnings. I started to fix them, usually expliciting   
   casting. Is it the way or is it better to avoid the warning from the   
   beginning, choosing the right signed or unsigned type?   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca