Brendan Long
Brendan Long

Reputation: 54252

Replace a macro with a different definition in Eclipse?

I'm working on a project which defines globals like this:

// Define an correctly-sized array of pointers to avoid static initialization.
// Use an array of pointers instead of an array of char in case there is some alignment issue.
#define DEFINE_GLOBAL(type, name, ...) \
    void * name[(sizeof(type) + sizeof(void *) - 1) / sizeof(void *)];

Which apparently works fine, but causes Eclipse to show every single usage of one of these globals as an error.

I would prefer that it be this:

#define DEFINE_GLOBAL(type, name, ...) \
    type name;

But I can't change this file, so is there a way to tell Eclipse to pretend that that's the macro's definition?

Upvotes: 0

Views: 78

Answers (1)

jetrost
jetrost

Reputation: 15

If you #define the preferred definition after the initial (unwanted) definition, Eclipse seems to use the most recent definition when it does the dynamic macro expansion.

Thus, if you re-#define the macro in the file you are editing, this may solve your problem.

Granted that this is a kludge and may cause unforeseen problems, it may work for your implementation.

Upvotes: 1

Related Questions