C++ static member function reported as undefined references by linker?

corey taylor corey.taylor@gmail.com
Sat Nov 5 21:23:00 GMT 2005


He was trying to use an old gcc version to compile some code that had
a global namespace declared class and static class method.

The issue was that the static class method wasn't given external
linkage in that version without declaring the class in a named
namespace.

For about a day, I mistakenly said it was appropriate behavior because
the class wasn't declared in a proper namespace, but after coming to
my senses and the spec, it clearly should have external linkage now
(2003 spec).

I gave him the work-a-round for that old gcc to simply declare the
class inside of a named namespace instead of global namespace.

corey

On 11/5/05, Nathan Sidwell <nathan@codesourcery.com> wrote:
> David Cespedes wrote:
> > Can you help with this issue, in regards to C++ static member functions and why they are reported as undefined references by the linker?
> >
> > Please see attached email trail!
>
> please provide a complete test case, I can't figure out from the email trail
> what you;re trying to compile.
>
> nathan
>
> --
> Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
> nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk
>
>



More information about the Gcc-help mailing list