|
-
March 31st, 2004, 02:56 PM
#1
VS C++ 6.0 has error in list.h?
In my project I declare a list:
Code:
#include <list.h>
list<unsigned> tsList;
and when I compile I get errors:
"c:\program files\microsoft visual studio\vc98\include\list.h(37) : error C2146: syntax error : missing ';' before identifier 'Length'
c:\program files\microsoft visual studio\vc98\include\list.h(37) : error C2501: 'DWORD' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\list.h(37) : error C2501: 'Length' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\list.h(53) : error C2146: syntax error : missing ';' before identifier 'GetPrevLink'
c:\program files\microsoft visual studio\vc98\include\list.h(53) : error C2433: 'WINAPI' : 'inline' not permitted on data declarations
c:\program files\microsoft visual studio\vc98\include\list.h(53) : fatal error C1004: unexpected end of file found"
I find it hard to beleive that the list header won't compile that is provided by microsoft, what am I doing wrong here?
thanks,
Devan
-
March 31st, 2004, 03:01 PM
#2
<list.h> is a depreciated header, use <list>
-
March 31st, 2004, 03:14 PM
#3
Regardles of that header file being deprecated, the problem, obviously, is with undefined windows-specific data types: DWORD, WINAPI. For those, you need to include <windows.h>, I think.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
March 31st, 2004, 03:23 PM
#4
Originally posted by VladimirF
Regardles of that header file being deprecated, the problem, obviously, is with undefined windows-specific data types: DWORD, WINAPI. For those, you need to include <windows.h>, I think.
not if you use <list> which does not rely windows specific types such as DWORD.
-
March 31st, 2004, 04:00 PM
#5
I changed it to #include <list> and I get more errors...
"c:\dev-cpp\fabsim\timelist.h(18) : error C2143: syntax error : missing ';' before '<'
c:\dev-cpp\fabsim\timelist.h(18) : error C2501: 'list' : missing storage-class or type specifiers
c:\dev-cpp\fabsim\timelist.h(18) : error C2059: syntax error : '<'
c:\dev-cpp\fabsim\timelist.h(18) : error C2238: unexpected token(s) preceding ';'"
line 18 is:
list<unsigned> tsList;
-
March 31st, 2004, 04:02 PM
#6
either use:
using namespace std;
list<unsigned> tsList;
or
std::list<unsigned> tsList;
-
March 31st, 2004, 04:05 PM
#7
Almost all compilers, even those complying with ISO standard, allow the use of the traditional header files (like iostream.h, stdlib.h, etc). Nevertheless, the ISO standard has completely redesigned these libraries taking advantage of the template feature and following the rule to declare all the functions and variables under the namespace 'std'.
The standard has specified new names for these "header" files, basically using the same name for C++ specific files, but without the ending '.h'. For example, 'iostream.h' becomes 'iostream'.
If you use the ISO-C++ compliant include files you have to bear in mind that all the functions, classes and objects will be declared under the 'std' namespace.
The following shows you the four different methods to map a namespace...
Code:
// Using the full member name, including the namespace it belongs to:
std::cout << "Hello World";
// By taking advantage of Using-Declarations:
using std::cout; // This declares cout in the current
// scope as synonym for std::cout
cout << "Hello World";
// By taking advantage of Using-Directives:
using namespace std; // Which specifies that the current
// scope can refer to names in the
// 'std' namespace without using
// full qualifiers. This is mostly
// used when porting legacy code.
cout << "Hello World";
// Using aliases:
namespace X
{
namespace Y
{
class Z { ... };
}
}
X::Y::Z // The full qualifier for 'Z' is
// 'X::Y::Z'
namespace w = X::Y; // This declares 'w' as an alias for
// namespace 'X::Y'
w::Z // Access 'Z' using 'w::Z'
-
March 31st, 2004, 05:07 PM
#8
thanks guys, I forget that one too often
-
March 31st, 2004, 11:02 PM
#9
Originally posted by Mick
not if you use <list> which does not rely windows specific types such as DWORD.
Look at the error messages; one of them says something about DWORD. Why is the compiler complaining about DWORD if DWORD does not exist anywhere in the source code?
-
April 1st, 2004, 07:21 AM
#10
Originally posted by Sam Hobbs
Look at the error messages; one of them says something about DWORD. Why is the compiler complaining about DWORD if DWORD does not exist anywhere in the source code?
The OP stated in the title they are using VC6.0, the code posted certainly doesn't seem like they are maintaining code that uses <list.h> therefore, I told them to stop using the depreciated header <list.h> and use <list>. DWORD needs to be defined for <list.h>, the typedef is NOT USED in <list>. Therefore the error becomes moot.
Does that clear it up?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|