🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.programmer
3 messages
3 total messages Started by Mauricio Tavares Tue, 24 Dec 1996 00:00
#ifndef/#ifdef problems in my header file (conditional header inclusion)
#3572
Author: Mauricio Tavares
Date: Tue, 24 Dec 1996 00:00
30 lines
2434 bytes
        I am finding some very interesting behavior from #define and
#ifndef/#ifdef.  Let's say that I have a header file called MyHeader.h.  This
file is included by all my routines (they usually are in separate files).  Now
that would not be very nice since it would include the very same include files
(stdio.h and others) over and over again.  So, I thought if I use something
like

#ifndef MOOSE
#define MOOSE
#include <stdio.h>
#include <X11/Xlib.h>
#endif

the code would only include *one* copy of these two include files.  What I am
finding out is that is not the case.  Running C programs that have similar 
conditional including of header files in gcc (Sparc), Think C (Mac), Borland
TC++ 3.1 for Windows (PC), and SAS/C (Amiga) results in the same thing.  It
really seems that the compiler simply *forgets* what was defined in the
previous .c file and define them all over again.  As a result, my object files
become unnecessarily large.  Yes, the executable seems to take care of that,
but still I am using more disk space than I should.  I am open for suggestions
as usual.

-- 
 ===========================+=======================================
| Mauricio Tavares          | "We will attack...                    |
| raub@kushana.aero.ufl.edu |  ...under the cover of daylight!"     |
|                           |                                Rimmer |
 ===========================+=======================================
Re: #ifndef/#ifdef problems in my header file (conditional header inclusion)
#3573
Author: Chao-Kuang Yang
Date: Tue, 24 Dec 1996 00:00
56 lines
3020 bytes
Hi!
	Have you ever try to put your header in MacHeader file or in pre-compiled
headers?  That might just do what you intend to do.

Mark Yang
-- 
----------------------------------------------------------------------------
----
MetaTools Program Team
email: ckyang@earthlink.net;
          myang@metatools.com;

Mauricio Tavares <raub@kushana.aero.ufl.edu> wrote in article
<raub-2412960039190001@dialup52.afn.org>...
>         I am finding some very interesting behavior from #define and
> #ifndef/#ifdef.  Let's say that I have a header file called MyHeader.h. 
This
> file is included by all my routines (they usually are in separate files).
 Now
> that would not be very nice since it would include the very same include
files
> (stdio.h and others) over and over again.  So, I thought if I use
something
> like
> 
> #ifndef MOOSE
> #define MOOSE
> #include <stdio.h>
> #include <X11/Xlib.h>
> #endif
> 
> the code would only include *one* copy of these two include files.  What
I am
> finding out is that is not the case.  Running C programs that have
similar 
> conditional including of header files in gcc (Sparc), Think C (Mac),
Borland
> TC++ 3.1 for Windows (PC), and SAS/C (Amiga) results in the same thing. 
It
> really seems that the compiler simply *forgets* what was defined in the
> previous .c file and define them all over again.  As a result, my object
files
> become unnecessarily large.  Yes, the executable seems to take care of
that,
> but still I am using more disk space than I should.  I am open for
suggestions
> as usual.
> 
> -- 
>  ===========================+=======================================
> | Mauricio Tavares          | "We will attack...                    |
> | raub@kushana.aero.ufl.edu |  ...under the cover of daylight!"     |
> |                           |                                Rimmer |
>  ===========================+=======================================
> 
Re: #ifndef/#ifdef problems in my header file (conditional header inclusion)
#3646
Author: Chao-Kuang Yang
Date: Tue, 24 Dec 1996 00:00
56 lines
3293 bytes
Hi!
	Have you ever try to put your header in MacHeader file or in pre-compiled
headers?  That might just do what you intend to do.

Mark Yang
-- 
----------------------------------------------------------------------------
----
MetaTools Program Team
email: ckyang@earthlink.net;
          myang@metatools.com;

Mauricio Tavares <raub@kushana.aero.ufl.edu> wrote in article
<raub-2412960039190001@dialup52.afn.org>...
>         I am finding some very interesting behavior from #define and
> #ifndef/#ifdef.  Let's say that I have a header file called MyHeader.h. 
This
> file is included by all my routines (they usually are in separate files).
 Now
> that would not be very nice since it would include the very same include
files
> (stdio.h and others) over and over again.  So, I thought if I use
something
> like
> 
> #ifndef MOOSE
> #define MOOSE
> #include <stdio.h>
> #include <X11/Xlib.h>
> #endif
> 
> the code would only include *one* copy of these two include files.  What
I am
> finding out is that is not the case.  Running C programs that have
similar 
> conditional including of header files in gcc (Sparc), Think C (Mac),
Borland
> TC++ 3.1 for Windows (PC), and SAS/C (Amiga) results in the same thing. 
It
> really seems that the compiler simply *forgets* what was defined in the
> previous .c file and define them all over again.  As a result, my object
files
> become unnecessarily large.  Yes, the executable seems to take care of
that,
> but still I am using more disk space than I should.  I am open for
suggestions
> as usual.
> 
> -- 
>  ===========================+=======================================
> | Mauricio Tavares          | "We will attack...                    |
> | raub@kushana.aero.ufl.edu |  ...under the cover of daylight!"     |
> |                           |                                Rimmer |
>  ===========================+=======================================
> 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads