delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/07/28/09:56:34

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: conditional compilation for typedef
Date: 28 Jul 2002 12:56:24 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 36
Message-ID: <ai0plo$k7r$1@nets3.rz.RWTH-Aachen.DE>
References: <ai04lk$7i$1 AT news5 DOT jaring DOT my>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1027860984 20731 137.226.32.75 (28 Jul 2002 12:56:24 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 28 Jul 2002 12:56:24 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Patrick Chen <pck66 AT pd DOT jaring DOT my> wrote:
> Use Rhide: C, djgpp.
> Dear All,
>     The files are as follows:
> mouse3.c - main file
> lmouse3_video.c - implementation file-video functions
> lmouse3_video.h- header file -video functions
> lmouse3_bitmap.c - implementation file- bitmap functions
> lmouse3_bitmap.h - header file - bitmap functions

> lmouse3_video.h contains:
> typedef unsigned short word;

> lmouse3_bitmap.h contains:
> typedef unsigned short word;

Bad planning here. Move common typedefs like this into a separate header file.
And have the usual multiple-inclusion guards around that (and all other header files):


	#ifndef LMOUSE3_TYPES_H
	#define LMOUSE3_TYPES_H

	/* ... contents here */

	#endif /* LMOUSE3_TYPES_H */

>    Is there a condition compilation statement that can be put to every
> header file, so that whenever the first one is found by the pre-processor
> the other one will be ignored?

No, because the preprocessor doesn't even know what a typedef is, so it can't
know whether it alreaady came by one of a given name, yet.
-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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