View Single Post
  #5   Spotlight this post!  
Unread 02-02-2006, 11:07
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Using vars across multiple .c files

Quote:
Originally Posted by Smithvillefirst
I've tried this, but it won't work. In a file globals.h, I have the following:
int myvar;

Then, in user_routines.c I have:
#include "globals.h"
extern int myvar;
That's exactly backwards. You should put the extern declaration in the .h file, and actually define the variable in only one .c file.