简体   繁体   中英

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" mean?

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM