For Programmers: Free Programming Magazines  


Home > Archive > VC STL > February 2005 > Re: STL error









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: STL error
Carl Daniel [VC++ MVP]

2005-02-14, 9:11 pm

MA wrote:
> Hello,
> I am beginner in STL and never use it in MSVC. I am developing an
> application DLL that I have a template for it which is based on STL.
> When I am trying to compile the template I will get the following
> error for this line of code. What is the problem and how can I solve
> it? Is it related to the way that I setup my MSVC?
> I am using MSVC 6 on window XP sp1:
>
> Line that generate error:
>
> typedef vector<string>::value_type value_type;


There's nothing wrong with that line provided that:

#include <vector>
#include <string>
using namespace std;

all appear before it in the file. If you could produce a minimal but
complete file that generates the error you're seeing and post it here it
would be much easier for someone to help you.

-cd


MA

2005-02-14, 9:11 pm

Thanks I add
use namespace std befoer this line and now it doesn't generate any error for
this line but I have error for the following lines:
line 67: typedef vector<string>::pointer pointer;
line 68: typedef vector<string>::const_pointer const_pointer;


the errors are:
c:\matlab701\toolbox\xilinx\sysgen\inclu
de\stringlist.h(67) : error C2039:
'pointer' : is not a member of 'vector<class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >,class
std::allocator<class std::basic_string<ch
ar,struct std::char_traits<char>,class std::allocator<char> > > >'
c:\matlab701\toolbox\xilinx\sysgen\inclu
de\stringlist.h(67) : error C2146:
syntax error : missing ';' before identifier 'pointer'
c:\matlab701\toolbox\xilinx\sysgen\inclu
de\stringlist.h(67) : error C2868:
'pointer' : illegal syntax for using-declaration; expected qualified-name
c:\matlab701\toolbox\xilinx\sysgen\inclu
de\stringlist.h(68) : error C2039:
'const_pointer' : is not a member of 'vector<class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> >,class std::allocator<class std::basic_str
ing<char,struct std::char_traits<char>,class std::allocator<char> > > >'
c:\matlab701\toolbox\xilinx\sysgen\inclu
de\stringlist.h(68) : error C2146:
syntax error : missing ';' before identifier 'const_pointer'
c:\matlab701\toolbox\xilinx\sysgen\inclu
de\stringlist.h(68) : error C2868:
'const_pointer' : illegal syntax for using-declaration; expected
qualified-name
c:\matlab701\toolbox\xilinx\sysgen\inclu
de\stringlist.h(146) : warning
C4251: '_strings' : class 'std::vector<class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >,class
std::allocator<class std::basic_string<char,s
truct std::char_traits<char>,class std::allocator<char> > > >' needs to have
dll-interface to be used by clients of class 'stringList'
Error executing cl.exe.


the last warning is for the following line:

vector<string> _strings;


Any help?
Sorry I didn't writre any code with STL and hence very simple and foolish
questions!

Best regards






"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam>
wrote in message news:uHRMyOx#EHA.1564@TK2MSFTNGP09.phx.gbl...
> MA wrote:
>
> There's nothing wrong with that line provided that:
>
> #include <vector>
> #include <string>
> using namespace std;
>
> all appear before it in the file. If you could produce a minimal but
> complete file that generates the error you're seeing and post it here it
> would be much easier for someone to help you.
>
> -cd
>
>



Gerd Orfey

2005-02-14, 9:11 pm

MA wrote:
> Thanks I add
> use namespace std befoer this line and now it doesn't generate any
> error for this line but I have error for the following lines:
> line 67: typedef vector<string>::pointer pointer;
> line 68: typedef vector<string>::const_pointer const_pointer;
>
>
> the errors are:
> c:\matlab701\toolbox\xilinx\sysgen\inclu
de\stringlist.h(67) : error
> C2039: 'pointer' : is not a member of 'vector<class
> std::basic_string<char,struct std::char_traits<char>,class
> ...


The message states it rather clear, there is no member pointer in
std::vector defined. Maybe you could learn faster if you would first
read a book about the usage of STL-Templates.

Try this one:
http://www.informatik.hs-bremen.de/~brey/stlbe.html

It's a free downloadable translation from a german book about
STL. The translation is not too good, but it has an quite pragmatic
approach and as a starter it might be sufficent.


Regards


Gerd

Stephen Howe

2005-02-14, 9:11 pm

> use namespace std befoer this line and now it doesn't generate any error
for
> this line but I have error for the following lines:
> line 67: typedef vector<string>::pointer pointer;
> line 68: typedef vector<string>::const_pointer const_pointer;


> Any help?


Carl asked, "If you could produce a minimal but
complete file that generates the error you're seeing and post it here it
would be much easier for someone to help you".

So where is your complete code example demostrating the problem?

Stephen Howe



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com