View Single Post
  #6 (permalink)  
Old October 2nd, 2004, 10:24 AM
davekw7x davekw7x is offline
Authorized User
 
Join Date: Feb 2004
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I finally played around with mingw32, and found that the following works. %I64 is the key (even though the documentation that I could find for dev-cpp seemed to indicate that %ll would work).

Code:
/* Use of 64-bit unsigned ints with mingw32 gcc */

#include <stdio.h>                                    
typedef long long Long;
int main(void)                                       
{                                                     
   long long juul = 123456789012345678LL;    
   unsigned char *pjuul;                              
   int i;                                             

   printf("With dev-cpp mingw32 gcc:\n\n");
   printf("sizeof(Long) = %d\n", sizeof (Long));
   printf("juuld: %I64d\n",juul);
   printf("juulx: %016I64X\n",juul);                  
   pjuul = (char *) &juul;                            
   printf("juulb: ");                                 
   for (i = 0;i < sizeof(juul); i++) printf("%02X",*(pjuul + i));
   printf("\n"); 
   system("pause");                                     
   return 0;
The results are

With dev-cpp mingw32 gcc:

sizeof(Long) = 8
juuld: 123456789012345678
juulx: 01B69B4BA630F34E
juulb: 4EF330A64B9BB601
Reply With Quote