This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/5721: link errors when using typedef struct {...}A;
- From: peter_broadhurst at ml dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 18 Feb 2002 16:10:17 -0000
- Subject: c++/5721: link errors when using typedef struct {...}A;
- Reply-to: peter_broadhurst at ml dot com
>Number: 5721
>Category: c++
>Synopsis: link errors when using typedef struct {...}A;
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Feb 18 08:16:06 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: peter_broadhurst@ml.com
>Release: 3.0.3
>Organization:
>Environment:
sparc-sun-solaris2.6
i386-redhat-linux (redhat 7.1)
>Description:
The files below give a link time error (undefined symbol A::f()) when compiled and linked.
If the definition of A::f() is moved to the same file where it is used, then the problem disappears.
if "struct A { void f(void); }; " is used, then the problem disappears.
nm indicates that a local-only definition of A::F() is placed in typedeflinkbug2.o.
Works in gcc 2.8.1
==> typedeflinkbug.h <==
typedef struct
{
void f(void);
} A;
==> typedeflinkbug1.cpp <==
#include "typedeflinkbug.h"
int main(int,char**)
{
A a;
a.f();
return 0;
}
==> typedeflinkbug2.cpp <==
#include "typedeflinkbug.h"
void A::f(void)
{
}
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: