delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/06/14:25:50

From: cybpunk AT geocities DOT com (John G)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: project
Date: Sat, 06 Mar 1999 03:41:26 GMT
Organization: UltraNet Communications , an RCN Company http://www.ultranet.com/
Lines: 55
Message-ID: <36e1a21d.74772283@news.ma.ultranet.com>
References: <l03130306b30719b02f86@[158.142.75.61]>
NNTP-Posting-Host: d48.dial-1.cmb.ma.ultra.net
Mime-Version: 1.0
X-Complaints-To: abuse AT ultra DOT net
X-Ultra-Time: 6 Mar 1999 18:57:01 GMT
X-Newsreader: Forte Agent 1.5/32.451
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I think you meant

#ifndef MYHEADER_H
#define MYHEADER_H
.
.
.
#endif


PS. (too the original poster)  (not sure of your experience level so I
will tell you how this works incase you are curious)  This allows
tells the compiler not to try and compile the file again if it's
already been defined, which causes errors.

ifndef -- if-not-defined
First time through MYHEADER_H is not defined so
#ifndef... 	=>true->drops through.
#define...	=> MYHEADER_H gets defined
so on.
next time
#ifndef		=>false->jump to #endif
#endif
eof

On Sat, 6 Mar 1999 11:44:15 -0600, John Meyer
<john_meyer AT geocities DOT com> wrote:

>>I have a problem with the PROJECT option in DJGPP :
>>
>>for example I to my project the files : file1.cpp , file2.cpp
>>
>>I include H files in file1.cpp , but if I need to use a few functions
>>from the same H files in file2.cpp I need to include the H files again.
>>When I compile and run the project , it writes me an error  that I
>>declared the same H files twice.
>>
>>How do I fix it?
>
>Okay, assuming that your header files are written by you, you have to put a
>sentinel in each of them.
>
>
>#ifdef MYHEADER_H       //notice the caps and underscore
>#define MYHEADER_H
>
>
>//code goes here
>
>
>#endif
>
>
>

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019