Thread overview
Error 42: Symbol Undefined
Mar 18, 2004
Alex Vinokur
Mar 18, 2004
Matthew
Mar 19, 2004
Alex Vinokur
Mar 22, 2004
Alex Vinokur
March 18, 2004
===========================================
Digital Mars C/C++ Compiler Version 8.40.2n
===========================================

DMC has a problem with the following program.


====== C++ code : BEGIN ======

--- File foo.h : BEGIN ---
#ifndef _FOO_H
#define _FOO_H

template <typename T1, typename T2, char T3>
T1 Fun();

template <typename T1, typename T2, char T3>
struct Bar
{
  T1 data_;
  Bar() { data_ = Fun<T1, T2, T3>(); }
};

#endif
--- File foo.h : END -----


--- File foo.cpp : BEGIN ---
#include "foo.h"
template<>
long Fun<long, double, 'a'>()
{
  return 100;
}
--- File foo.cpp : END -----

--- File foo_main.cpp : BEGIN ---
#include "foo.h"
int main ()
{
Bar<long, double, 'a'> b;
  return 0;
}
--- File foo_main.cpp : END -----

====== C++ code : END ========


====== Compilation : BEGIN ======

$ dmc -I. -IC:/dm/stlport/stlport foo_main.cpp foo.cpp
foo_main.cpp:
foo.cpp:
link foo_main+foo,,,user32+kernel32/noi;
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

foo_main.obj(foo_main)
 Error 42: Symbol Undefined ??$Fun@JN$0GB@@@YAJXZ

--- errorlevel 1

====== Compilation : END ========

--
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html




March 18, 2004
Looks to me like you've tried to specialise a function template, and that is not a valid thing to do in C++; not pre-C++05, anyway.

"Alex Vinokur" <alexvn@connect.to> wrote in message news:c3cpv1$17ob$1@digitaldaemon.com...
>
> ===========================================
> Digital Mars C/C++ Compiler Version 8.40.2n
> ===========================================
>
> DMC has a problem with the following program.
>
>
> ====== C++ code : BEGIN ======
>
> --- File foo.h : BEGIN ---
> #ifndef _FOO_H
> #define _FOO_H
>
> template <typename T1, typename T2, char T3>
> T1 Fun();
>
> template <typename T1, typename T2, char T3>
> struct Bar
> {
>   T1 data_;
>   Bar() { data_ = Fun<T1, T2, T3>(); }
> };
>
> #endif
> --- File foo.h : END -----
>
>
> --- File foo.cpp : BEGIN ---
> #include "foo.h"
> template<>
> long Fun<long, double, 'a'>()
> {
>   return 100;
> }
> --- File foo.cpp : END -----
>
> --- File foo_main.cpp : BEGIN ---
> #include "foo.h"
> int main ()
> {
> Bar<long, double, 'a'> b;
>   return 0;
> }
> --- File foo_main.cpp : END -----
>
> ====== C++ code : END ========
>
>
> ====== Compilation : BEGIN ======
>
> $ dmc -I. -IC:/dm/stlport/stlport foo_main.cpp foo.cpp
> foo_main.cpp:
> foo.cpp:
> link foo_main+foo,,,user32+kernel32/noi;
> OPTLINK (R) for Win32  Release 7.50B1
> Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved
>
> foo_main.obj(foo_main)
>  Error 42: Symbol Undefined ??$Fun@JN$0GB@@@YAJXZ
>
> --- errorlevel 1
>
> ====== Compilation : END ========
>
> --
>    Alex Vinokur
>      mailto:alexvn@connect.to
>      http://mathforum.org/library/view/10978.html
>
>
>
>


March 19, 2004
"Matthew" <matthew@stlsoft.org> wrote in message news:c3cubk$1fbo$1@digitaldaemon.com...
> Looks to me like you've tried to specialise a function template, and that is not a valid thing to do in C++; not pre-C++05, anyway.
[snip]

GNU g++ 3.3.1, Microsoft C++ 13.00.9466, Borland C++ 5.5.1 have no problem with that code.

--
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html




March 22, 2004
"Alex Vinokur" <alexvn@connect.to> wrote in message news:c3e0qb$ael$1@digitaldaemon.com...
>
> "Matthew" <matthew@stlsoft.org> wrote in message news:c3cubk$1fbo$1@digitaldaemon.com...
> > Looks to me like you've tried to specialise a function template, and that is not a valid thing to do in C++; not pre-C++05, anyway.
> [snip]
>
> GNU g++ 3.3.1, Microsoft C++ 13.00.9466, Borland C++ 5.5.1 have no problem with that code.
>

Perhaps, there is any option in link.exe (OPTLINK (R) for Win32  Release 7.50B1) which enables to compile/link the program in my
original message?

--
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html