• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

C programming: _t?

brjames

Member
What does it mean when there is a _t as part of a data type? For example: page_t, caddr_t, sigset_t, req_entry_t

Is this some type of standard nomenclature? If so what does it mean? Will I break stuff if I ignore this convention?
 
AFAIK, it's just a way of splitting up variable names to make them easier to read (but harder to type 🙂)
Now IIRC, by convention, variables with double leading and/or trailing underscores like __MyVar__ are variables, functions or macros within the libraries, so you should avoid using this convention to avoid possible conflicts.
 
Well it's not "_t" itself but foo_t, etc. I have noticed this practice a lot myself. And about the underscores, I was just reading the "good C coding practices" thing on developerworks that got posted to /., and it said that you shouldn't use anything that begins or ends with any number of underscores, as those are often used by "system" libraries or whatever. But then again, so are a lot of other names, so I don't see why those are a special case.
 
Originally posted by: BingBongWongFooey
Well it's not "_t" itself but foo_t, etc. I have noticed this practice a lot myself. And about the underscores, I was just reading the "good C coding practices" thing on developerworks that got posted to /., and it said that you shouldn't use anything that begins or ends with any number of underscores, as those are often used by "system" libraries or whatever. But then again, so are a lot of other names, so I don't see why those are a special case.

I think the convention is that, in system libraries, names that are exposed to the global namespace are prepended with underscores ... for example, the top of fstream.h:

#ifndef _FSTREAM_H
#define _FSTREAM_H
#ifdef __GNUG__
#pragma interface
#endif
#include <iostream.h>

extern "C++" {
class fstreambase : virtual public ios {
#ifdef _IO_NEW_STREAMS
mutable filebuf __my_fb; // mutable so rdbuf() can be const
#endif
void __fb_init ();
public:
 
I think I actually ran into this just recently. I am working on a project involving the kernel of OpenBSD. Here is a line of code from the kernel file kern_synch.c

fixpt_t ccpu = 0.95122942450071400909 * FSCALE; /* exp(-1/20) */

I believe the question is what does the _t in fixpt_t refer to? I am clueless as to what the answer is but I believe that the answers above this post may not be answering the right question.
 
Back
Top