View Single Post
  #5   Spotlight this post!  
Unread 08-02-2004, 11:34
Adam Shapiro's Avatar
Adam Shapiro Adam Shapiro is offline
Registered User
FRC #0555 (Montclair Robotics)
Team Role: Alumni
 
Join Date: Jan 2002
Rookie Year: 2001
Location: Montclair, NJ
Posts: 401
Adam Shapiro has much to be proud ofAdam Shapiro has much to be proud ofAdam Shapiro has much to be proud ofAdam Shapiro has much to be proud ofAdam Shapiro has much to be proud ofAdam Shapiro has much to be proud ofAdam Shapiro has much to be proud ofAdam Shapiro has much to be proud ofAdam Shapiro has much to be proud of
Send a message via AIM to Adam Shapiro
Re: Global Constants

Quote:
Originally Posted by Darkman_X000
What exactly do you mean by "globally-included header file"? When you use #define to create a global constant, it does not have a type. Do you have to typecast it whenever you use it?
I meant that you can use a #define statement in a header (for example "globals.h") that is included in any file that needs that variable. When you use a #define statement the variable name that you create will be replaced later (not sure of which but either by the compiler or the linker..probably compiler). Hence, the variable that you create with #define would be constant, you can not modify it. You can, however define variables using extern which would be globally accessable (see 'Global Variables, anyone?').

Quote:
Originally Posted by Darkman_X000
In C++ you can declare global constants using const varType varName = initialValue; Is this acceptable in C?
Unfortunately I am more of a C++ programmer, myself, so I do not really know an answer to this one. Perhaps somebody else can field this question?'Global Variables, anyone?'
__________________
Mentor to Teams 555, 1929, and 2070!
Currently working in hardware design at Cisco.
Cornell University DARPA Urban Challenge - http://www.cornellracing.com
Co-Captain Team 555 - 2003,2004,2005
Trust, Love, and Magic

Last edited by Adam Shapiro : 08-02-2004 at 11:38.