Solved

compiling templates in VC++ 5.0

Posted on 1997-04-22
4
404 Views
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
one.
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>;
39:
40:    public:
41:      NILNode_c();
42:
43:    private:
44:        T           Data;
45:        NILNode_c   *Next,
46:                    *Back;
47:};

--------------------Configuration: dtwin - Win32 Debug--------------------
Compiling...
DT_DLL.CPP
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)
0
Comment
Question by:mkhare
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Expert Comment

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

Author Comment

by:mkhare
ID: 1162901
Edited text of question
0
 

Accepted Solution

by:
snemanov earned 50 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
0
 

Author Comment

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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

615 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