www.digitalmars.com         C & C++   DMDScript  

c++ - Error 42: Symbol Undefined

reply "Alex Vinokur" <alexvn connect.to> writes:
===========================================
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
Mar 18 2004
parent reply "Matthew" <matthew stlsoft.org> writes:
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
Mar 18 2004
parent reply "Alex Vinokur" <alexvn connect.to> writes:
"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
Mar 18 2004
parent "Alex Vinokur" <alexvn connect.to> writes:
"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
Mar 21 2004