Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / October 2004

Tip: Looking for answers? Try searching our database.

STL compile error when moving from VS .NET 2002 to 2003

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phil McCarthy - 06 Oct 2004 12:15 GMT
Hi All,

I have recently upgraded my VS .NET from 2002 to 2003 edition and having
problems with code that compiles on the old version but not in the new
version.

I am using the STL functions MAP and LIST.  I am creating thread-safe
versions of both of these, using a template class.  However the compiler is
throwing errors at me (C2146, C2501) as if it doesn't recognise the STL
classes.

eg

std::map<_key, _value>::const_iterator GetNext(bool* islast);

throws error "C2146 missing ';' before identifier GetNext"

This code, when compiled under the 2002 edition of .NET compiles fine.  Does
anyone have any clue why it is not working.  (NB: I have already checked
http://support.microsoft.com/default.aspx?scid=kb;en-us;154419 - it is
nothing there.  And yes, I am including namespace std in the code)

Many thanks,
-Phil
Steve McLellan - 06 Oct 2004 14:00 GMT
The other obvious one is have you included <map>? Are you able to just
declare a map on its own?

Steve

> Hi All,
>
[quoted text clipped - 20 lines]
> Many thanks,
> -Phil
Phil McCarthy - 06 Oct 2004 17:27 GMT
Yeah, thanks but that is included with #include <map> (and #include <list>).

Microsoft say they have tightened up the standards required for templates
between 2002 and 2003 so that 2003 needs to conform more to the ANSI
standard.  The example they give is that you must preceed the declaration of
the template with the namespace, eg use

std::map<X, Y> instead of
map<X, Y>

however as you can see from the below I am already doing that.  I was
wondering if anyone knew of any other 'tightening up of the ANSI standards'
that might be causing this... ?

-Phil

> The other obvious one is have you included <map>? Are you able to just
> declare a map on its own?
[quoted text clipped - 27 lines]
> > Many thanks,
> > -Phil
Steve McLellan - 06 Oct 2004 22:01 GMT
The main one we found was that 'typename' had to be applied far more often
when compiling templated code. Can you provide a small compileable example?
It would help you and us locate the problem. Try creating a map like the one
that's causing the problem in a simple CPP, and listing the exact error
messages. My guess is that the problem's down to your template parameters,
not map itself.

I've got to go and get some food - it's ridiculously late to be at work. See
if you can narrow down the problem a bit, and I or someone else'll have a
look.

Steve

> Yeah, thanks but that is included with #include <map> (and #include <list>).
>
[quoted text clipped - 43 lines]
> > > Many thanks,
> > > -Phil
Steve McLellan - 07 Oct 2004 12:11 GMT
The other thing that occurs is that there are two newsgroups, dotnet.vc and
languages.vc that specialise in VC++. There're a lot of standards experts in
there who may be able to give you a list of standards compliance
differences.

Steve

> Yeah, thanks but that is included with #include <map> (and #include <list>).
>
[quoted text clipped - 43 lines]
> > > Many thanks,
> > > -Phil

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.