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
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.