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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 calling functions

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
rpaczkowski Posted - 04/01/2005 : 3:29:21 PM
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.

3   L A T E S T    R E P L I E S    (Newest First)
rpaczkowski Posted - 04/04/2005 : 09:42:14 AM
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

easwar Posted - 04/02/2005 : 08:33:12 AM
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
Leo_Li Posted - 04/01/2005 : 8:42:15 PM
change the last character of your code to '}' ?
(or it is a typo when you post the message?)

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000