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
 Origin C function

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
a.abc.b35 Posted - 01/27/2011 : 11:04:12 AM
This is very elementary I guess. I have written a few origin C programs which have the same function within their body. Now if I have the same name for them in two separate programs, it gives me an error during compilation saying the function already has a body as that program was already compiled. At present I rename the functions, say if the function name in one program is myfunction than in the next program , i shall rename it to myfunction1. But can anyone tell me how I can do it without ever needing to change the name of the functions ? Can I make a separate file for the functions (like in C or C++) and call the function from there for all the programs ? Please help. I hope the question is clear.

AB
2   L A T E S T    R E P L I E S    (Newest First)
a.abc.b35 Posted - 02/02/2011 : 4:27:56 PM
Thank you Penn. :-)

AB
Penn Posted - 01/27/2011 : 9:17:56 PM
Hi AB,

Commonly, a function you defined in Origin C can be used as a LabTalk command, which can run in Command Window, Script Window, etc, so the function name should be unique.

If you just want to used the function in its defined file, you can use the static function. In this way, the same function name can be used in different file. However, you cannot use this function as a command.
For example:

In test1.c file, there is a function defined as below, which can only be called by the other function defined in test1.c file.

static void test()
{
	out_str("test in test1.c");
}

In test2.c file, you can also defined a static function named test for other functions.

static void test()
{
	out_str("test in test2.c");
}

However, when you try to run command test in Command Window, error message is "#Command Error!", that is to say the function test cannot be run as a command.

Penn

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