Reputation: 35
What are the ways in which I could make an executable to expose a function's parameters as command line parameters. I know of using
int main( int argc, char **argv )
Are there alternatives ? Is it possible to invoke this program from a script language such as javascript?
Upvotes: 0
Views: 264
Reputation: 44354
You need to write your program as a DLL (Windows) or .so (UNIX) file, which does not have a main(). To call that from a scripting language generally will require wrapper code to convert between the scripting language variables and conventions to C. Although many scripting languages are written in C, you can't pass variables direct between the two without some sort of conversion.
Upvotes: 0
Reputation: 35049
The main
function provides an entry point for executables. So, the answer is no, you cannot simply expose a function, which is called from a scripting language like javascript.
I know of possibilities to enable access to a C or C++ libraries and functions for certain scripting languages like Python, Ruby, Lua, etc. If you want to expose functions to any of these I can suggest SWIG, Boost::Python or luabind. I am sure there are a lot of other libraries to expose interfaces to scripting languages, and who knows, even to javascript.
I hope I got the question right :)
Upvotes: 1