Go to Post you know you're going to meet someone important, so you put on your robotics team shirt. - NorviewsVeteran [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
  #3   Spotlight this post!  
Unread 17-01-2004, 10:45
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Using the extern keyword.

no, do not define the variable in user_routines.h - this does not actually share the variable. instead, you get two copies, one in each file. (remember, putting something in an include file is just like inserting that text into each file in which you #include it). if you look at the user_routines.h file, you will notice that there is not a single actual variable defined there - there's a reason for that.

extern is probably the way to go here, just declare the variable in one file, then copy the definition to the other but tack "extern " on the front. if you're passing more than one thing back and forth, you might consider creating a struct to keep all of the info in one single variable that can be extern-ed (having more than one or two global variables looks messy )

if you wanted to be ambitious, you could modify main.c so that Process_Data_From_Local_IO() and Process_Data_From_Master_uP() could return and be called with a value, thus passing the info that way (using a struct)
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
 


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