View Single Post
  #3   Spotlight this post!  
Unread 07-02-2004, 10:51
Darkman_X000 Darkman_X000 is offline
Registered User
#0612
 
Join Date: Feb 2004
Location: Chantilly, VA
Posts: 8
Darkman_X000 is an unknown quantity at this point
Re: Global Constants

Quote:
Originally Posted by Adam Shapiro
You can use a #define statement in a globally-included header file to create global constants. You can also use extern to define global variables.
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?

For example:
Code:
user_routines.c
#define axelWidth 1234
...
void fn(void)
{
...
x*=axelWidth;      //Can it be this?
x*=(int)axelWidth; //Or must it be this?
x=x*(axelWidth);   //This seems to be the only form that the compiler likes
...
}
...
In C++ you can declare global constants using const varType varName = initialValue; Is this acceptable in C?

Please clarify!!!