From: Lostgallifreyan <z....@bt...> - 2013-08-17 23:21:00
|
Keith Marshall <kei...@us...> wrote: (18/08/2013 00:06) >On 17/08/13 23:29, Lostgallifreyan wrote: >> I am using Windows API, hence Windows.h. (And stdlib.h, math.h, >> commctrl.h and mmsystem.h). > >Fine. If you need it, include it. If you use printf(), you should also >include stdio.h; if you want explicitly sized integer data types, >include stdint.h; if you also want to printf() them, include inttypes.h >instead, and use the PRI?N formatting macros it defines. > Thanks. I'll save that one for reference. I got the PR bit workign too, found something on Stackoverflow while waiting for mail, and so far I have this, which works: #include <stdio.h> #include <inttypes.h> uint64_t X=22222222220000UL; int main(){ printf("%d %d %d %d\n",X>0xFFFFFFFF,X==22222222220000,(X*2)==44444444440000,(X*2/10000)==4444444444); printf("%"PRIu64" %"PRIu64" %"PRIu64"\n",X,X*2,X*2/10000); } >Alternatively, since you've already locked yourself into the Microsoft >world, (by including windows.h -- and you should *never* refer to it as >Windows.h, because that breaks cross-compiles on case sensitive file >systems), you could just use Microsoft's idioms throughout, e.g. >__uint64 coupled with "%I64u", (I think -- I never use these >non-portable idioms myself). > I try not to do this. :) The 'Windows.h' is a typo, habit written by hand. No caps in my header names... I'm trying to avoid locking into Windows, I'm just using it for now because I know it a bit, and it allows me use my audio hardware painlessly. >> Defining a QWORD in my own files if fine, I'd rather do that then >> change the others. What I was getting at is: I don't want to include >> things if I don't have to. Less parts, less to go wrong, usually.. > >Not so, when it comes to including system headers; you must include each >and every one which declares the APIs you wish to use. > And the exactly matching point is to NOT include anything I do not need. This is like the 'glass half full/empty' debate. >> I tried including stdint.h and inttypes.h because you mentioned >> printf, to see if that fixed the printf output I described in an >> earlier mail, but it didn't. I don't know what to do to fix that. > >Just including the headers isn't enough. See my other reply; in the >case of printf() formatting, in particular, you must also *use* the >macros they define. > See above. :) |