Go to Post Bottom line for us is this... By elevating what ANY team can do, we also push those outstanding teams to go even further. - Rich Kressly [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Spotlight this post!  
Unread 18-01-2004, 02:07
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Re: Using the extern keyword.

Quote:
Originally Posted by SeanCassidy
Hmm, when the variable is changed in user_routines.c, do you have to extern it back in u_r_f.c? Like so:

Code:
/*user_routines_fast.c*/
int foo = 263;
extern user_routines_function();    /*Is this extern needed?*/
extern foo = foo - 1;               /*Do we need the extern now,
                                     *because it was modified in u_r.c?*/

/*user_routines.c*/
user_routines_function()
{
  extern foo = foo + 3;
}
extern should never be used inside an expression like that. It is only used in declarations made at the file-scope level. Thus, you just do stuff like this:

/*user_routines_fast.c*/
int foo;

void myfunc(){
foo=foo+1;
}

/*user_routines.c*/
extern int foo;

void myfunc2(){
foo=foo+3;
}


They keyword extern is NEVER needed with function prototypes, as they are extern implicitly.

-Rob
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 19:56.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi