View Single Post
  #12   Spotlight this post!  
Unread 14-02-2004, 22:30
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: printf isn't printf-ing. Help!

Quote:
Originally Posted by deltacoder1020
never put the keyword "extern" in a header file - the whole point of extern is that it points to a variable declared in another file. If you put the "extern"-ed variable declaration in the header file, you'll either have two definitions of the variable, or no definition without "extern" (you always have to have one without extern).

just put "extern" variable declarations at the beginning of an individual file.
He already declared counter in user_routines.c. If he puts an "extern" declaration in the header file, the variable will become static (extern is a type of statically declared variable), and able to be referenced by any file that includes "user_routines.h" (including user_routines.c). This is the way I typically declare a global var since my team has 10 programmers (6 students and 4 mentors) and every student has thier own .c file to work on.

Back on topic:
Code:
unsigned long longvar = 0xFAAABBBB;
unsigned int shortvar = 0;
shortvar = longvar;
You will get an overflow error with this code. You need to right shift out the 16 least significant bits of longvar and assign shortvar to the 16 most significant bits as shown here:
Code:
shortvar = (unsigned int)(longvar >> 16);
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"