1

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.

3
  • 8
    Kill it with fire. May 28, 2014 at 13:48
  • Careful with tools that generate "stuff" (including docs) from headers/definitions and might use that token for something.
    – Mat
    May 28, 2014 at 13:52
  • 1
    ... 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.
    – user395760
    May 28, 2014 at 13:52

1 Answer 1

6

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 far pointer and sometimes a near pointer. The macro makes it possible to switch the entire codebase from one to the other if the need arises.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.