Crear un #define para el asterisco del puntero

I am working on an API that, I think, dates from the 80s and the original architect of the API is not working in our company anymore. The API, let's call it ABC API is defined in a public header file abc.h that contains following definition:

#define ABC_PTR_DECL *

and then later in many places in the header file:

typedef unsigned char uint8, ABC_PTR_DECL uint8_ptr;

The question is, why would someone #define the ABC_PTR_DECL and not use the asterisk directly? Are there / were there reasons to have it defined so it can be easily changed in one place?

I'd like to remove this definition in a newer API revisions but I've always wondered why do we have it this way.

preguntado el 28 de mayo de 14 a las 14:05

Kill it with fire. -

Careful with tools that generate "stuff" (including docs) from headers/definitions and might use that token for something. -

... and if, by pure perversity of the universe, there is a legitimate problem that this works around, find a better work around and document its existence and reasons. Had the original architect done this, you wouldn't have to ask this question. -

1 Respuestas

The only reason that I can think of is that, in the bad old days of MS-DOS and the 286, memory was segmented so sometimes you needed a puntero lejano and sometimes a near pointer. The macro makes it possible to switch the entire codebase from one to the other if the need arises.

contestado el 28 de mayo de 14 a las 14:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.