C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old March 1st, 2003, 02:39 AM
7stud 7stud is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2001
Posts: 1,327 7stud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 44 m 50 sec
Reputation Power: 9
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.

Reply With Quote
  #2  
Old March 1st, 2003, 03:52 AM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 8
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.

Reply With Quote
  #3  
Old March 1st, 2003, 06:33 AM
7stud 7stud is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2001
Posts: 1,327 7stud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 44 m 50 sec
Reputation Power: 9
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.

Reply With Quote
  #4  
Old March 1st, 2003, 08:25 AM
pschmerg pschmerg is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: Blacksburg VA/Philly PA
Posts: 38 pschmerg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m
Reputation Power: 6
Send a message via AIM to pschmerg
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

Reply With Quote
  #5  
Old March 3rd, 2003, 11:03 AM
7stud 7stud is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2001
Posts: 1,327 7stud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 44 m 50 sec
Reputation Power: 9
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > header files and VC++6


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway