Skip to content

const typedef pointers #384

@cshorler

Description

@cshorler

looking in exp2cxx I see function prototypes including statements like this:

void TYPEenum_inc_print( const Type type, FILE * inc )

presumably the intention is along the lines of const char *p i.e. p / type param target won't be changed. However, libexpress defines:

typedef struct Scope_ * Type;

Perhaps due to the age of the code, typedef of pointers hasn't before been recognised as bad practice. Also, the use of the types is not treating the pointers as opaque - so why do this?

I tested fixing this in several ways:

  1. remove typedefs to force compile errors and iterate until fixed.
  2. adjust typedefs to remove the pointer, rename e.g. typedef struct Scope_ Scope;
  3. adjust typedefs to remove the pointer e.g. typedef struct Scope_ Type;

option 1 is my currently favoured approach.
option 2 - not convinced less typing is a good argument.
option 3 - feels like C++ masquerading as C (with this I can assign Type t to Procedure p... yuk!)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions