Tuesday, 3 September 2013

why nginx don't use basic types directly?

why nginx don't use basic types directly?

the code is from ngx_config.h
typedef intptr_t ngx_int_t;
typedef uintptr_t ngx_uint_t;
typedef intptr_t ngx_flag_t;
the prototype of intptr_t is int, and the corresponding to uintptr_t is
u_int.
seems a sophisticated type hierarchy is set by nginx designer. i am just
confused why they don't use basic type directly?
In fact this kind of type hierarchy makes code a bit sophisticated.
i know this hierarchy can make it easy when you try to modify some type
from A to B but simply change one line of code which can also lead to
better portability, that is change typedef A xxtype to typedef B xxtype,
but i wonder if this kind of type hierarchy is over used in nginx? anybody
here who could any clues about this over use staff?
what's more, you can also tell more benefits or tricks about this kind of
design:)

No comments:

Post a Comment