How to name enums and object types in C

by Jon Deaton   Last Updated September 10, 2017 17:05 PM

I am writing a lisp interpreter in C and am running into interesting naming collision problem. I am using lisp objects that can point to either a lisp list, atom, or primitive object. The first of bytes the object are dedicated to an enum:

enum type {atom_obj, list_obj, primitive_obj};

which specifies which kind of object. The following bytes are of variable length depending on the type of object as shown below.

enter image description here

I was using the following typedefs to specify pointers to the contents of the object after the enum header.

typedef char* atom_t;
typedef struct {
  obj* car;
  obj* cdr;
} list_t;
typedef obj*(*primitive_t)(obj*);

However, after reading answers to this question I have discovered that the _t suffix is reserved in POSIX and I should not be using it. This leaves me with the interesting problem of renaming list_t, atom_t, and primitive_t. I have a few questions that

  1. How should I name enums that are used to specify the type of a object? Specifically, what would be better names for atom_obj, list_obj, primitive_obj
  2. Are there any conventions other than the _t suffix to distinguish names of types from other things. I don't want to rename atom_t to atom because I already have a primitive function named atom.

Thank you.

Related Questions

Naming a view class

Updated June 14, 2017 19:05 PM

Interface naming, IAm, ICan, I<something>

Updated May 04, 2015 21:02 PM