c – What does the _t suffix mean and when to use it?


I see in a lot of code some variables with the suffix _t . There are a lot of examples in the standard C library like size_t , int32_t , mbstate_t .

What is the use, and when to use this suffix?


It is a convention that indicates that name represents a data type (t of type ). It is used not to be confused with other code identifiers.

As far as I know it was created to avoid conflicts with existing code as originally these types did not exist and someone could have used these names in something in the code, which would have caused compilation problems. Some consider it just to make it clear that it is a type and not a variable.

In your codes it is not usually so useful to use it and it is rare to see people using it in their types. The same goes for libraries. Personally I find almost all C conventions bad and poorly thought out, some I understand why, but I don't agree.

I prefer to use capital letters.

Scroll to Top