This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Forward declaration issue (error: previous declaration of 'tst' was here)


Is there anyway to allow typedef redefinition? since I can assure there will
be no ambiguity... same typedef will be in all places...



Hani Ayoub wrote:
> 
> If I do so, I'll have to write "struct _tst" instead of "tst" when I use
> the struct... 
> 
> 
> 
> Baurzhan Ismagulov wrote:
>> 
>> On Sun, Nov 30, 2008 at 12:03:05AM -0800, Hani Ayoub wrote:
>>> tst.h
>>> =======
>>> typedef struct _tst{
>> ...
>>> } tst;
>> 
>>> tst2.h
>>> =======
>>> #include "tst.h"
>>> typedef struct _tst tst;
>>> 
>>> int foo(tst t);
>> 
>>> tst.c
>>> =======
>>> #include <stdio.h>
>>> #include "tst2.h"
>>> 
>>> int foo(tst t){ return 1; };
>> ...
>> 
>>> when compiling: "gcc tst.c tst2.h tst.h" I get the following errors:
>> ...
>>> The problem is that "tst" is redefined... but I cannot change "tst.h"
>>> file... 
>> 
>> So, what about:
>> 
>> * Removing the typedef from tst2.h -- "tst" is already typedefed in
>>   tst.h.
>> 
>> * Compiling tst.c only, not the headers.
>> 
>> With kind regards,
>> -- 
>> Baurzhan Ismagulov
>> http://www.kz-easy.com/
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Forward-declaration-issue-%28error%3A-previous-declaration-of-%27tst%27-was-here%29-tp20755376p20758009.html
Sent from the gcc - Help mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]