What does this macro do?

I am doing a project and using projects from yesteryear to help me get ideas on how to do certain things. Note that I am not mindlessly copying, but there are many things that are not in the book. Anyway, here's a macro that I don't understand:

#define PREPAREENTRY(numIVT,oldINT) \
    void interrupt int##numIVT(...){\
            IVTEntry::entries[##numIVT]->signalAll();\
            if (oldINT) IVTEntry::entries[##numIVT]->callOld();}\
    IVTEntry entry##numIVT(##numIVT,int##numIVT); 
#endif

      

I'm not entirely sure, but I think I got most of this. Thus, PREPAREENTRY gets two values: numIVT (number in table IV) and OldNT (old interrupt).

It then performs an interrupt function whose name is numIVT, which can later be set as an interrupt function for a specific interrupt, or what happens when that interrupt occurs.

The new interrupt function calls signalAll () on a specific object from an array of objects depending on numIVT. Then it checks if it should call the old interrupt function and call it or not.

This is the end of the new interrupt function.

But what does the line do before #endif? I have been looking all over the project and cannot find an answer. Before looking at this project during my brainstorming session, I thought of something similar, but without the last line.

If anyone could tell me if I am right or wrong about the parts, I think I hanged myself, and if anyone can tell me that this is a mysterious line, that would be greatly appreciated.

+3


source to share


2 answers


Let's assume numIVT=1

. The last part of the macro will be expanded to:

IVTEntry entry1(1, int1); 

      



This means that you define an object of the type IVTEntry

and use 1

and int1

(the function declared in the same macro) as arguments to the constructor.

+6


source


The last line declares an IVTEntry object named entry ** and initializes it with a number and the function just defined.



+1


source







All Articles