Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Prototypes
Page 1 of 1

PostPosted: Sat Jan 06, 2001 12:46 pm
by DaveEverett
Can someone please show me what a function prototype should look like?

Thanks.

PostPosted: Sat Jan 06, 2001 8:59 pm
by wolfgang
Hello,

the prototype looks exactly like a function header, except that it is terminated with a ";" and no function body follows. Example:

Function:

my_func (int my_var)
{
// do something
}

The prototype for this function would be

my_func (int my_var);

In regular C you can omit the parameters variable names (I don't know if PocketC allows this, too):

my_func (int);

Wolfgang

PostPosted: Sun Jan 07, 2001 3:04 pm
by tclarke
Why would I need to use these in PocketC?

What purpose do they serve in PocketC?

Tom

PostPosted: Sun Jan 07, 2001 10:38 pm
by DaveEverett
Thanks for the info.

I need prototypes to avoid a chicken and egg problem during compilation. Apparently I can't call a sub until it's been compiled.

Creating the prototypes fixed the problem.

PostPosted: Mon Jan 08, 2001 12:59 am
by tclarke
Just to make sure I understand, the purpose of a prototype is to enable me to put the 'real' functions in any order, as long as the prototypes are at the beginning of the program. Right?
Is there any other reason to use prototypes?

Tom

PostPosted: Mon Jan 08, 2001 6:12 pm
by slmiller
That's pretty much all they do. The reason they are needed is to avoid problems with functions calling other functions during compilation. The problem could be avoided by copying/pasting the functions around to put them in the right order, but it is obviously simpler to just rearrange your single-line prototypes.

Duct tape is The Force. It has a light side, a dark side, and it holds the world together.

PostPosted: Mon Jan 08, 2001 10:54 pm
by wolfgang
There is one other reason (actually the one why they are used most of the time): You can put all the prototypes (without any code) into a header file (.h) and have the actual functions in a separate c file (.c, or .pc for PocketC). In that way one can separate nicely definition and implementation, very useful for libraries etc. There might not even be the source code for the .c file available, only the compiled object file to be linked to the full program (that's only possible in regular C, not in PocketC). You can still use the functions in your code by including the header files with the prototypes.

Wolfgang

PostPosted: Tue Jan 09, 2001 1:44 am
by tclarke
Thank you, all. Now it makes sense...

Tom