Naming conventions in UNIX C functions (_t and _st)
I notice that there are some function return types named *****_t
or ******_st
. What do "_st" and "_t" mea开发者_开发问答n?
POSIX reserves names ending _t
for types. Although it is quite common to see code that invents its own type names ending _t
, doing so is dangerous - you can run into POSIX systems that define a (different) type with the same name.
In the libmemcached source, it looks like the _st
suffix is used to indicate a structure type:
types.h:typedef struct memcached_st memcached_st;
types.h:typedef struct memcached_stat_st memcached_stat_st;
types.h:typedef struct memcached_analysis_st memcached_analysis_st;
types.h:typedef struct memcached_result_st memcached_result_st;
types.h:// All of the flavors of memcache_server_st
types.h:typedef struct memcached_server_st memcached_server_st;
types.h:typedef const struct memcached_server_st *memcached_server_instance_st;
types.h:typedef struct memcached_server_st *memcached_server_list_st;
I didn't find a single instance of a function ending _st
(but I may not have looked hard enough).
精彩评论