| Adam Shapiro |
08-02-2004 11:34 |
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?'
|