Go Premium for a chance to win a PS4. Enter to Win


compiling templates in VC++ 5.0

Posted on 1997-04-22
Medium Priority
Last Modified: 2008-03-06
I get a syntax error compiling the following template in
VC++ 5.0. The code is the winsock sdk code available from
microsoft. The code compiled under the old developer studio.
I could not find any option to get it compiled in the new
I add line numbers to the code:

36:template<class T> class NILNode_c {
37:    friend class NIDeque_c<T>;
38:    friend class NIDequeIter_c<T>;
40:    public:
41:      NILNode_c();
43:    private:
44:        T           Data;
45:        NILNode_c   *Next,
46:                    *Back;

--------------------Configuration: dtwin - Win32 Debug--------------------
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(37) : error C2059: syntax error : '<'
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(37) : error C2238: unexpected token(s) preceding ';'
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(38) : error C2059: syntax error : '<'
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(38) : error C2238: unexpected token(s) preceding ';'
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(69) : error C2989: 'NIDeque_c' : template class has already been defined as a non-template class
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(114) : error C2059: syntax error : '<'
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(141) : error C2588: '::~NIDeque_c' : illegal global destructor
C:\winsock\SAMPLES\DT_DLL\dtwin\nideque.h(141) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.

dtwin.dll - 8 error(s), 0 warning(s)
Question by:mkhare
  • 2
  • 2

Expert Comment

ID: 1162900
Please, mark what line is #37 ?

Author Comment

ID: 1162901
Edited text of question

Accepted Solution

snemanov earned 100 total points
ID: 1162902
Formally, friend class X; is not a class declaration.There was some disorder with it in the previous compiler versions.MSVC++ 5.0 has more strong approach to types declaration,so you should define NIDeque_c and NIDequeIter_c classes as template classes before NILNode_c class.Addtemplate<class T> class NIDeque_c;
template<class T> class NIDequeIter_c;
lines before the line #36 or include an appropriate header file.Feel free to ask additional questions if any.Regards, Sergey

Author Comment

ID: 1162903
i have compiled the code successfully using your suggestion

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question