From mboxrd@z Thu Jan 1 00:00:00 1970 From: pdovera Subject: Re: #include problem Date: Fri, 15 Oct 2004 19:04:29 +0200 Sender: linux-c-programming-owner@vger.kernel.org Message-ID: <4170031D.4010309@bmind.it> References: <200410151648.i9FGmlqM026477@students.fct.unl.pt> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <200410151648.i9FGmlqM026477@students.fct.unl.pt> List-Id: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: C-16 , linux-c-programming@vger.kernel.org C-16 wrote: >Howdy, >i have a file main.c in my program that needs to include four headers >aaa.h , bbb.h ,ccc.h and ddd.h . Each one of these headers need to >include another header xxx.h . With this implementation i get a >"redefinition" compilation error. How can i solve this problem ? Thanks >in advance. >- >To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in >the body of a message to majordomo@vger.kernel.org >More majordomo info at http://vger.kernel.org/majordomo-info.html > > > Hi, If I understand well the redefinition problem is generated by xxx.h, so you need to include xxx.h only once. into each file aaa.h, bbb.h, ccc.h, try the following code: #ifndef xxx_h #include "xxx.h" #endif so you will include xxx.h only once ! xxx_h will not be included only the first time, the second time the ifndef will be false (since xxx.h is already included) and so on ... Ciao, Paolo Dovera