views:

398

answers:

3

Possible Duplicate:
What does a type followed by _t (underscore-t) represent?

While typing in my IDE (Xcode), autocomplete pops up already-defined words when I'm partway thru entering some variable name. I occasionally see names that have '_t' at the end of them.

  1. What naming convention is that and what does it mean?

  2. Is there a reference document to look up pre- and post-fixes in common use?

Searching with the term "postfix" gives me a lot of GoogleNoise about the mail server of the same name.

+1  A: 

based only on my own experience, the "_t" postfix means "data type". In other words, it's a datatype defined used typedef.

nairdaen
+3  A: 

The t stands for "type" or "typedef." You'll see a lot of POSIX headers (and others) with time_t, size_t, and others. These which hold (not necessarily defined) specific bit-sizes based on the operating system and machine architecture.

Sufian
Also in standard C: size_t, wchar_t, wint_t, clock_t, not to mention the integer types such as int8_t, uint16_t, ... Actually, all the 'POSIX' types mentioned in the answer are defined first in the C standard and only secondarily in POSIX (because it uses the C standard). There are plenty of POSIX-only types ending in '_t' too: ino_t, dev_t appear in `<sys/stat.h>`, for example, and gid_t, uid_t, mode_t, and ...
Jonathan Leffler
A: 

The "_t" suffix is a convention for data type names such as size_t or wchar_t. It's not used consistently.

John Bode
I believe the `_t` suffix was largely POSIX, but then ANSI decided to incorporate some POSIX features as being kind of important. I can't be sure of that, but the first POSIX standard was released in 1988, so they were definitely happening around the same time.
Chris Lutz
The first C standard was released in 1989, but was largely ready a year or two earlier as the (ANSI) C standard committee tried to get final agreement on the I18N/G11N/L10N aspects of the standard - in particular <locale.h>. But you're right - the (IEEE) POSIX and C standards were developed at very much the same time. The ISO POSIX standard was first released in 1990, the same year as ISO C, IIRC.
Jonathan Leffler