LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-09-2005, 04:51 PM   #1
The_Nerd
Member
 
Registered: Aug 2002
Distribution: Debian
Posts: 540

Rep: Reputation: 32
Function pointers, calling, and templates


Hello! I need to do the same thing in my code that Boost.Python does. Namely, this:

Code:
int Function(int Var1, int Var2, char Var3, long Var4)
{
....
}

int Function2(int Var1)
{
....
}

char Function3(bool Bar1)
{
....
}

InitFunctions()
{
    def("Function", Function);
    def("Function2", Function2);
    def("Function3", Function3);
}
I then need to be able to loop through the list of function names (strings) and call them acordingly.

Example:

Code:
int MyVar, MyVar2;
char MyVar3;
long MyVar4;

CallFunction("Function", MyVar, MyVar2, MyVar3, MyVar4);
I am using C++, so I can use templates, macros, what ever. I just don't know where to even start, so please help me! I am very stuck in my code until I figure this out. Thanks!
 
Old 10-09-2005, 05:29 PM   #2
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
Python is a high-level interpreted language, so you can do things like calling functions in weird ways and stuff; but C++ is a more low-level compiled language. You can have pointers to functions, but they are still strongly typed, so I don't think there is an easy general way to refer to functions by name or something.
 
Old 10-09-2005, 07:08 PM   #3
The_Nerd
Member
 
Registered: Aug 2002
Distribution: Debian
Posts: 540

Original Poster
Rep: Reputation: 32
I just need to know the arguments at compile time. I can write wrappers (I figured I would have to). I am attempting to make my own simple scripting language. I got almost everything figured out, except function calling. I want my scripting language to tie into the C++ program very easily. You know, like you just do something like so:

Code:
DataType(int);
And that will enable you to use native int's in the scripting language. Of course user specified classes will be a freature as well, even though they might be a little more complicated. I just don't want the user to have to write a function for every aspect of everything, and in every function have to parse out there args.

Help!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling another function from a function using GTK geminigal Programming 4 07-11-2005 03:15 PM
Function pointers in C. Matir Programming 2 03-15-2005 03:10 PM
switch statements calling a function tekmorph Programming 2 10-19-2004 05:53 PM
calling a system function directly from C program appas Programming 8 08-03-2004 01:50 AM
Calling my function through MACROS in OpenOfficeWriter mcp_achindra Linux - Software 0 07-05-2004 06:56 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration