![]()
Hi. I’m Tomasz Sterna and this is my blag.
I am real-time messaging and XMPP consultant, Software Configuration Manager and Open Source Developer.
Reach me via e-mail or Jabber: smoku@xiaoka.com
You may also visit My Company Website.
It’s not that easy to get printf format right. Especially with esoteric datatypes such as size_t or other *_ts. You may need to resort to #include <inttypes.h> and PRI* macros defined there.
For example:
#include <inttypes.h>
uint32_t val;
printf("val is: %"PRIu32", unsigned 32 bit", val);Object-oriented programming is the current cure-all — although it has been around for much more then ten years. At the core, there is little more to it then finally applying the good programming principles which we have been taught for more then twenty years. […] it turns out that you can do just as well with plain ANSI-C.
[…] I had fun discovering that ANSI-C is a full-scale object-oriented language.
Object-Oriented Programming With ANSI-C
This is pretty convoluted…
int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 };
Or an real-life example coming from man getsubopt(3):
enum {
RO_OPT = 0,
RW_OPT,
NAME_OPT
};
char *const token[] = {
[RO_OPT] = "ro",
[RW_OPT] = "rw",
[NAME_OPT] = "name",
NULL
};
It seems extraordinary that just about every C project ends up developing it’s own logging system.
While there are environments like embedded systems or operating system kernels that may justify customized logging technology (and there are open source projects aimed at those areas) there seems to be no a priori reason why most user level application and server software written in C cannot share a logging library.