Question

I would like to be able to do one or more of the following from the shell: - call any function from the program not only the main - pass parameters that are not only strings (not only argv) - have a program return not only int (the return code from main) - assign returned values to shell-level variables to be able to pass them to other programs

You get the idea. For instance python toplevel allow this for python programs. What about C++? Or a ELF replacement on linux that would allow that?

Was it helpful?

Solution

If you looking for an operating system that does this - the vxWorks shell/C interpreter does this.

But, it's vxWorks - a realtime operating system (no GUI).

OTHER TIPS

It's not too difficult to come up with an app that allows you to call certain functions by name from dynamic libraries such as DLLs under Windows, provided those functions take only a limited selection of parameter types such as ints, floats and fixed strings.

However, for most C++ programs this is not sufficient. For example, suppose your C++ function takes s std::map of dynamic string to socket as a parameter - how are you going to create the map, to say nothing of its contents in your shell?

But if you can forgo C++, there is one language cum operating system that does exactly what you suggest - Smalltalk. If you are interested in this paradigm, take a look at Squeak, which is free software.

Under Windows, there is RUNDLL32 to call DLL function, eg

RUNDLL32.EXE USER32.DLL,SwapMouseButton

Have you looked at c-repl?

The system would have to be completely interpreted, right? And how would you know the function signatures of the things you were calling?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top