==> Wednesday, June 24, 2009 <==

The "standard" C library?




for a long time, each C compiler provided a "standard" library, but we know all the "standard" C library just a joke, they are not so "standard" actually. especially in cross-platform development, depend on the difference in compiler's design and the point of view, each compiler will add to or removed some behavious in the C library, just as type different : socklen_t defined in linux but windows not, SOCKET_ERROR defined in windows but linux not, even different headers with a same function, that lead us to have to increase expenditure : the sucking things of #ifdef LINUX ... #elif WIN32 ... #elif MACOX ... #endif goes everywhere in our codes just take a compromise of them.

so i always search for a cross-platform base library seems like the "standard" C library, it must have some characteristic list below:

(1). it must base on the current compiler's C library.

(2). it must have the same types and the same api similar to the "standard" C library, and needn't to change you code when you using different compiler and in different operating system.

(3). it must compatible with the types and apis in C library. ( for example : you could use socket() to create a socket handle or do the same with compatible api compatible_socket(), you could operate the handle by send() or by compatible_send(), it should invoke without difficulty on local C library api or compatible apis. )

(4). all api's behavious predictable, execute situation the same on different compiler and operating system.

(5). it must dependence less except the C library from compilers.

may be someone will ask why not try the GLib?

the GLib is a good choice for C, and it's an excellent C utilities library, but it's not the thing i searching for. first, it implement all things independent of C library, though it could convert some basic C type to the types it using( just as FILE ), what's not my willing to do. second, it toooooo GNU's, it must compile in the unix like environment with pkg-config ( ex : cygwin, msys, linux ... ), it depend on libintl, libiconv, etc ... third, in some cross-platform developments, the hardware and the environment decide it couldn't use so large a library ( you know, some compiler we have to use will compile all the library into the executable file, that greatly enlarge the last executable file size. ), and it seems so much dependences. may be it's also the reason why so much independent C package don't choice GLib as the base backend and implement their tiny compatible base layer ( ex : SDL, FreeImage, tinyxml ... ).

actually, we need at last is : a library compatible to C standard library with similar apis ( removed all platform / compiler characteristic ).

i haven't seem there have something like this yet, may be it exist but i don't know.

after a long long time waitting, i decided to implement it myself finally ...