Before I read that POSIX reserved the typedefs ending in _t
I used it frequently. What would be a good commonly-used standard alternative for this suffix?
Asked
Active
Viewed 359 times
3

tversteeg
- 4,717
- 10
- 42
- 77
-
4I think that's up to you, as long as you make it a standard in your code. – moffeltje Mar 17 '15 at 12:46
-
If I were you, I just wouldn't use a postfix >o – ikh Mar 17 '15 at 12:47
-
There's no definitive right or wrong. The only thing that is *more* right is to be consistent. – gustafbstrom Mar 17 '15 at 12:56
-
`_type`. Anyways, it's really up to you and therefore opinion-based. What matters is consistency. – edmz Mar 17 '15 at 13:01
-
I understand that you need to be consistent with your naming conventions, but I was wondering if there is a *standard* for it. – tversteeg Mar 17 '15 at 13:02
-
1As others have said, consistency is key. Also, the _t_t reservation is a convention honored more in the breach than in observance. Just like the fact that all identifiers beginning with strstr are reserved by the C standard library (thus, variable names like streetAddressstreetAddress should not be used). Frankly I see little value in the `_t` suffix. Such type names are used where you would expect to see one of the built in types (i.e. ∫int, float,float, char` etc) and can therefore be nothing other than a typedef or possibly macro, but we ALL use UPPER_CASE for that , don't we? – kdopen Mar 17 '15 at 13:42
-
something odd going on in SO - I hit the limit on characters and it started replacing backticked sequences like `_t` with _t_t – kdopen Mar 17 '15 at 13:47
-
I've experimented with [`_T`](http://stackoverflow.com/a/1186232/2410359) with some success. – chux - Reinstate Monica Mar 17 '15 at 15:50
1 Answers
2
"Standard" is a big word. If you refer to the ISO C, it's beyond its job to define that; indeed, it does use names like time_t
or size_t
because it's allowed to as POSIX is secondary to it. Moreover, this convention does not apply to Windows-based programming environments, for instance.
IMHO, it's not really needed to state that a type is a type. C has a limited number of types so it's elementary to determine whether it's a built-in type or an ADT. Also, such built-in types have lower case one word names: if you saw stat_buffer
you would immediately know it may not be a built-in type.
Whatever choice you make it's important to keep it consistent across your source code. Anyways, very frequent choices I see may be:
- Uppercase nomenclature, like
Time
orPid
_type
suffix, liketime_type
orpid_type
- Invisible suffix, like
time
orpid

edmz
- 8,220
- 2
- 26
- 45