Penguin
Diff: CPortabilityNotes
EditPageHistoryDiffInfoLikePages

Differences between version 2 and predecessor to the previous major change of CPortabilityNotes.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 2 Last edited on Tuesday, January 25, 2005 9:57:02 pm by PerryLorier Revert
Older page: version 1 Last edited on Tuesday, January 25, 2005 12:29:09 pm by JohnMcPherson Revert
@@ -7,7 +7,17 @@
  
 [BSD]-style unixes uses flock(2), which uses "advisory" locks. Ie, a process with sufficient read or write permission can ignore the lock and read/write a file. [SysV]-style unixes use either advisory locks or "mandatory" locks (if enabled in the filesystem), and access them by the fcntl(2) command and a <tt>struct flock</tt> object. 
  
 A more portable way (POSIX 1003.1-2001) is to use the lockf(3) function from unistd.h, which will do the correct type of locking for the unix it is compiled on. (In Linux/GNU libc, this function is a wrapper around fcntl(2)). 
+  
+!!!printf types  
+!64bitisms and fixed sized types  
+If you have a fixed sized type (eg, uint64_t) and you want to use printf to display it, you need to know the real type of the integer. eg:  
+ uint64_t x;  
+ printf("%llu",x);  
+This however will fail on 64bit machines as uint64_t is "long" not "long long". The best solution to this that I've found is to typecast it to the longer of the types and use that. eg:  
+ uint64_t x;  
+ printf("%llu",(long long unsigned)x);  
+Better solutions solicited.  
  
 ---- 
 Part of CategoryProgramming