.oO  |  List directory  |  History  |  Similar  |  Print version
Projects 
   ScummC 
   php edna 
   nixshare 
   concede 
   Orewar 
   AEval 
Portable Coding 
   Shell scripts 
   Standard C 
Random stuff 
   Slackware and UTF-8 
   Bit tricks 
Wiki 
   Links 
   Playground 
   Impressum 

Portable Coding > Standard C

 
rw-rw-r--   albeu   portable
Table of contents:

Standard C

The current C standard is C99. However most (if not all) implementations have some lacks.

Some paltform (like GNU/Linux) have pretty flexible system headers. When using system functions things will often compile just fine even without all headers listed in the man page. However this will break on many other platforms, always include all header listed in the man pages, preferably in the given order.

Types

Use inttypes.h rather than stdint.h, the former exist on much more systems, sadly not on all. For full portability a replacement have to be available.

Time

On posix system gettimeofday() and nanosleep() can be used for subsecond timers. BSD (and most posix) also have the handy usleep(). On win32 their is timeGetTime() and Sleep().

Some systems have timers with higher precision. Linux have /dev/rtc, Darwin have the mach_time API.

Files and directories

On win32 mkdir() doesn't take a mode argument, only a path.

glob() is evidently not avaible on win32. However windows provide FindFirstFile() and FindNextFile() which can be used to implement glob().



Reference http://alban.dotsec.net/PortableCoding/StandardC

Comments: 0 New comment

Prev. Shell scripts