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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I've a forward declaration problem...

Have this files:
=======
tst.h
=======
typedef struct _tst{
        int x;
        int y;
} 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; };

int main()
{
        tst hani_tst;

        return 0;
}

================================

when compiling: "gcc tst.c tst2.h tst.h" I get the following errors:
In file included from tst.c:2:
tst2.h:2: error: redefinition of typedef 'tst'
tst.h:4: error: previous declaration of 'tst' was here
tst2.h:2: error: redefinition of typedef 'tst'
tst.h:4: error: previous declaration of 'tst' was here

The problem is that "tst" is redefined... but I cannot change "tst.h"
file... 
Any advice to a solution would be appreciated!
-- 
View this message in context: http://www.nabble.com/Forward-declaration-issue-%28error%3A-previous-declaration-of-%27tst%27-was-here%29-tp20755376p20755376.html
Sent from the gcc - Help mailing list archive at Nabble.com.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux