The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 calling functions
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

rpaczkowski

USA
Posts

Posted - 04/01/2005 :  3:29:21 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5 SR5
Operating System: Win 2000 Pro

Hello everybody,
How can I call a function? My program looks (basically) like this:

#include <Origin.h>


void test()
{
testminimum ();
}
void testminimum(void)
{
//many command lines
)

When compiling, I get the error message "Function already has a body", however, everything seems to work just fine.

Leo_Li

China
Posts

Posted - 04/01/2005 :  8:42:15 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
change the last character of your code to '}' ?
(or it is a typo when you post the message?)
Go to Top of Page

easwar

USA
1965 Posts

Posted - 04/02/2005 :  08:33:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Apart from the typo that Leo pointed out, it looks like the problem you are having is that you have more than one function in your workspace with the same name and prototype. You did not paste the entire error message and so not clear if that error pointed to your function named test(), or some other function. You should check the contents of your current workspace.

Note that Origin C allows function overloading, so that you can have multiple functions of the same name, provided they are of different prototypes (in terms of arguments and returns etc).

So something like the following is allowed:

// function 1
void test(int nn)
{
// code
}

// function 2
void test(double dd)
{
// code
}

//function 3
int test(int n1, int n2, double dd)
{
// code
return 0;
}



whereas something like below is not allowed:

// function 1
void test(int nn)
{
// code
}

// function 2
void test(int ii)
{
// some other code
}



Note also that if you have overloaded/multiple functions of same name (with different prototypes as in the first example), all the functions become accessible from other Origin C code. However, from LabTalk, such as from script window, only one of the functions of that name becomes available. It is not necessarily the first function by the way in the code, that becomes available in script.

Easwar
OriginLab



Edited by - easwar on 04/02/2005 08:38:39 AM
Go to Top of Page

rpaczkowski

USA
Posts

Posted - 04/04/2005 :  09:42:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you for your help. I had another function that called a function called testminimum with the same arguments. Deleting it took care of the problem.

Ralph

P.S. The ) was a typo, it's really a } and the complete error text was C:\Program Files\OriginLab\OriginPro75\RP01\OriginC\test.c(20) :Error, Function already has a body

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000