The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
header files and VC++6
Discuss header files and VC++6 in the C Programming forum on Dev Shed. header files and VC++6 C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

March 1st, 2003, 02:39 AM
|
|
Contributing User
|
|
Join Date: Feb 2001
Posts: 1,365

Time spent in forums: 18 h 9 m 25 sec
Reputation Power: 14
|
|
|
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.
|

March 1st, 2003, 03:52 AM
|
|
Contributing User
|
|
Join Date: Jan 2002
Location: Seattle WA
Posts: 863
  
Time spent in forums: 22 sec
Reputation Power: 13
|
|
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.
|

March 1st, 2003, 06:33 AM
|
|
Contributing User
|
|
Join Date: Feb 2001
Posts: 1,365

Time spent in forums: 18 h 9 m 25 sec
Reputation Power: 14
|
|
|
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.
|

March 1st, 2003, 08:25 AM
|
|
Contributing User
|
|
Join Date: Nov 2002
Location: Blacksburg VA/Philly PA
Posts: 38
Time spent in forums: 2 h 29 m
Reputation Power: 11
|
|
|
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
|

March 3rd, 2003, 11:03 AM
|
|
Contributing User
|
|
Join Date: Feb 2001
Posts: 1,365

Time spent in forums: 18 h 9 m 25 sec
Reputation Power: 14
|
|
|
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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|