From: Keith.S.Thompson+u@gmail.com   
      
   Bart writes:   
   [...]   
   > /Some/ compilers with /some/ options will /sometimes/ tell you when   
   > you've got it wrong.   
   >   
   > But you first have to make an educated guess, or put in some dummy   
   > format code.   
   >   
   > Eventually, it will compile. Until someone else builds your program,   
   > using a slightly different set of headers where certain types are   
   > defined, and then it might either give compiler messages that they   
   > have to fix, or it show wrong results.   
      
   That's not how I do it, and I don't think it's how most programmers do   
   it.   
      
   I know the rules well enough that I can usually write a correct format   
   string in the first place. If I make a mistake, gcc's warnings are a   
   nice check.   
      
   > If I compile this code with 'gcc -Wall -Wextra -Wpedantic':   
   >   
   > #include    
   >   
   > int main() {   
   > int a = -1;   
   > printf("%u", a);   
   > }   
   >   
   > it says nothing. The program displays 4294967295 instead of -1.   
      
   The behavior is unsurprising. The lack of a warning is very mildly   
   inconvenient.   
      
   > If compile this version (using %v) using a special extension:   
   >   
   > #include    
   >   
   > int main() {   
   > int a = -1;   
   > printf("%v", a);   
   > }   
   >   
   > it shows -1. Which is better?   
      
   The one I can actually use.   
      
   --   
   Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com   
   void Void(void) { Void(); } /* The recursive call of the void */   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|