How about extending the C++ compiler ?

  • Ionut Popia

    Ionut Popia - 2009-05-31

    In Pascal there is a very powerful capability of the language: dynamic methods (or message-handling methods for those Pascal compilers which support Delphi). That is, virtual methods which are identified not by their name, but by an integer index which the programmer supplies when declaring the method. I think this would simplify VERY much writing a GUI toolkit library - in C++, because there are only virtual member functions, linking a message and a message-handling member function requires A LOT of artificial stuff. I say this because I don't like using the dedicated libraries like Borland OWL, Microsoft MFC etc etc which are huge as compared to what I need. I just want to make (and I made it) my own tiny GUI toolkit and use it. But in C++, I still find this very awkward - you cannot control the index that a virtual member function gets when it is declared, it just gets the next available value and you need to declare all the possible message handlers and also write the code to translate the message index to the index of the message handler member function.

    • Kai Tietz

      Kai Tietz - 2009-06-02


      The design of vtables is pretty much compiler specific. So if you want to provide such features, gcc project is maybe the best place for it. Possibly the new plugin-feature could be some help here for you.
      The otherway you can implement this, is using manual class-tables (like DCOM is using). So you can access the members via index. And by doing this, you are idependent of the compiler you are using.

      struct myVClass {
         void (*foo1)(void);
         int (*foo2)(struct mySecondClass *);



Log in to post a comment.