www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/16/20:11:02

From: Matthew Mastracci <mmastrac AT acs DOT ucalgary DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Why two identical typedef are considered an error in DJGPP?
Date: Wed, 15 Jan 1997 08:24:02 -0700
Organization: The University of Calgary
Lines: 37
Message-ID: <Pine.A41.3.94.970115082052.92882A-100000@acs2.acs.ucalgary.ca>
References: <01IE7MKQWZ2Q003361 AT cc DOT uab DOT es>
NNTP-Posting-Host: mmastrac AT acs2 DOT acs DOT ucalgary DOT ca
Mime-Version: 1.0
In-Reply-To: <01IE7MKQWZ2Q003361@cc.uab.es>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Tue, 14 Jan 1997, x DOT pons AT cc DOT uab DOT es wrote:

> If I write something like this in a xxx.h file
> 
>   typedef unsigned char BYTE;
> 
> and I have *THE SAME* typedef in some other yyy.h file,
> both included in the same .c file, the DJGPP compiler complains
> that:
> 
>   file xxx.h line n  redefinition of `BYTE'
>   file yyy.h line m  `BYTE' previously declared here

> Is there some way to avoid this error, which is not even a warning
> in other compilers (provided, of course, that both definitions are
> identical)?

Try encapsulating the line with a define that checks for an arbitrary
conditional (ie: BYTEdefined) and if it is not set, sets it and then
defines the conditional.  

Pseudocode:

if not defined "BYTEdefined"
define "BYTEdefined"
declare BYTE
end if

Put this in both places and you should have no problem with either one, no
matter which order they are compiled in.

/\/\att /\/\astracci                  mmastrac AT acs DOT ucalgary DOT ca

GCS/GE    d- s+:+ a--- C++++ UA P+ L E-- W+ N++ o K+ w+ O M- V 
          PS++ PE++ Y+ PGP t+++ 5+++ X++ R++ tv+ b+++ DI++++ I 
          G++ e h r* z?

- Raw text -


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