Can C++11 cannot dynamically call function?

Pages: 12
Chapter 8 of Jimmy Coplien's 'Advanced C++ Programming Styles and Idioms' (terribly dated, but the ideas are still applicable) would describe one way of approaching this.

(The examples in the book deal with polymorphic construction of objects based on data read at run-time from files. This particular problem is somewhat simpler.)
Last edited on
1. No languages other than C or C++ can be used for this - this limitation is imposed by the fact that this must be a DLL loaded by an external application which I have no control over.
2. Nothing can be done about this at compile, it must all be done at runtime - this limitation is imposed by the requirement that the external definitions file may be changed at any time without the need to recompile the original source C++ code. THis has to do with extending functionality of the DLL for the software's Java/iOS/Flash/etc ports - if an actionscript port is written that requires additional functions but the C++ code is not available or does not need to implement such functions, the external definitions file can be edited for this and at C++ the generic function handler is used to 'do nothing', while at Flash runtime the actionscript port gets to handle the functions. (The software was not originally designed with portability in mind so workarounds are running rampant)
3. There is already a working solution by using inline assembly to push the parameters in a loop and then call the function. I only started this thread because I was curious if there was a pure C++11 way to do this instead.

So far the answer to my original question seems to be "no, C++11 cannot do that" and "you need to use a reflection library". Thanks, all I needed to know - the solution in place already works and there are no plans to change it under these circumstances. I was merely curious if there was.

If anyone IS interested in what in the world I am talking about, you can check out the project here: https://github.com/Andos/Edif (not made by me, I was simply attempting to support it)

Thank you for all your time and effort, I appriciate it - I can consider these things when I work on my own projects if I should ever need them.
I am developing a graphical project where there can be a number of different output devices. Not all output devices are capable of drawing all objects.

I use code generation to stuff the abstract base class of the output device with blank virtual functions. This ensures the vtable can cater for any attempted object draw.

The code generator looks in a folder (shapes), lists all header files there and generates the virtual draw functions drawShape()

If a new header file is added to the shapes folder than the date stamp on this folder is updated. Then a rebuild will run the code generation and add a new virtual function.

In this way you can add shapes as you like and the project always compiles. If there is no code to draw the shape then its simply not drawn.
Did you not read my previous post or something? I've already explained why that is not possible for this situation.
Topic archived. No new replies allowed.
Pages: 12