|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
header files and VC++6
My book says that to add preprocessor directives to prevent a file from being included more than once you can type them in your self, or select Tools/Macro and select OneTimeInclude in the Macro dialog box. When I try that, I find the Macro dialog box is totally blank. If I type in OneTimeInclude and hit return, I get an error saying I have to select a macro from the list--but the list is empty.
|
|
#2
|
|||
|
|||
|
You probably need to define the macro. Eitherway, it's trivial to code by hand:
Code:
#ifndef __FOO
#define __FOO
class Foo {
};
#endif
Just pick an appropriate symbol to define. First you check to see if your symbol is not defined. If so, then you define it along with the class. If it is, then nothing is done. |
|
#3
|
|||
|
|||
|
I think the macro provides random symbols to define so that each header file has a unique symbol. I'm going to download the service pack for VC++6 and see if that changes anything--it's only a 10.5 hour download after all.
|
|
#4
|
|||
|
|||
|
It is considered good practice to use the name of the file in all capitals, and replacing the period (.) with an underscore (_)
#ifndef EXAMPLE_H #define EXAMPLE_H . . . #endif |
|
#5
|
|||
|
|||
|
Ok, I finally figured out how to access that macro. If anyone is interested:
Without any files open in VC++6, you need to click on Tools/Macro, and in the Macro dialog box that appears, you have to click on Options then Loaded Files, and in the Customize dialog box that appears with the "Add-ins and Macro Files" tab selected, you need to enable the macro Sample by clicking on the check box, and then click on Close. Thereafter, when you click on Tools/Macro you can select Sample as the "Macro File:" from the drop down list, and then you'll be able to select OneTimeInclude from the list of macros. When you run that macro, it will automatically insert preprocessor directives in your .h file. There are also some other macros in the list that I'm sure would be useful too. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > header files and VC++6 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|