473,406 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Dumb STDLib Deprecation Question

I just upgraded my server to a recent version of redhat, and now old
code no longer compiles. I'm not a C++ coder, but C++ coders who use
my server are now complaining. Here's an example:
#include <iostream>
#include <list>
#include <string>

using namespace std;

template<typename T>
void writeList(const list<T>& alist, const string& separator = " ")
{
list<T>::const_iterator iter;
for(iter = alist.begin(); iter != alist.end(); iter++)
cout << *iter << separator;
cout << endl;
}
int main()
{
return 0;
}

And I get this error:

t1.cpp: In function âvoid writeList(const std::list<T,
std::allocator<_CharT&, const std::string\
&)â:
t1.cpp:11: error: expected `;' before âiterâ
t1.cpp:12: error: âiterâ was not declared in this scope

The user who gave me this example claims that STD lib is somehow not
installed correctly on the new server, but I can't figure out what I
could install additionally. My (completely naive) guess is that his
code is deprecated.

Here's what I can find that might be relevant:

$ cd /usr/lib
$ find . -print | grep libstd
../libstdc++.so.5
../libstdc++-3-libc6.2-2-2.10.0.so
../gcc/x86_64-redhat-linux/4.1.1/libstdc++.a
../gcc/x86_64-redhat-linux/4.1.1/32/libstdc++.a
../gcc/x86_64-redhat-linux/4.1.1/32/libstdc++.so
../gcc/x86_64-redhat-linux/4.1.1/libstdc++.so
../libstdc++.so.6
../libstdc++.so.5.0.7
../libstdc++.so.6.0.8
../libstdc++-libc6.2-2.so.3

Thanks in advance!

May 27 '07 #1
4 1667
On May 26, 8:47 pm, "JShra...@gmail.com" <JShra...@gmail.comwrote:
I just upgraded my server to a recent version of redhat, and now old
code no longer compiles. I'm not a C++ coder, but C++ coders who use
my server are now complaining. Here's an example:

#include <iostream>
#include <list>
#include <string>

using namespace std;

template<typename T>
void writeList(const list<T>& alist, const string& separator = " ")
{
// the following is a dependant type.
list<T>::const_iterator iter;
// fix:
typename list<T>::const_iterator iter;
for(iter = alist.begin(); iter != alist.end(); iter++)
cout << *iter << separator;
cout << endl;

}

int main()
{
return 0;

}

And I get this error:

t1.cpp: In function âvoid writeList(const std::list<T,
std::allocator<_CharT&, const std::string\
&)â:
t1.cpp:11: error: expected `;' before âiterâ
t1.cpp:12: error: âiterâ was not declared in this scope

The user who gave me this example claims that STD lib is somehow not
installed correctly on the new server, but I can't figure out what I
could install additionally. My (completely naive) guess is that his
code is deprecated.
The code is deprecated but considering how long dependant types have
been ignored, its really not his fault. You might consider suggesting
that he look up the use of 'typename' in the context of dependant
types. Yours is a classic example.
>
Here's what I can find that might be relevant:

$ cd /usr/lib
$ find . -print | grep libstd
./libstdc++.so.5
./libstdc++-3-libc6.2-2-2.10.0.so
./gcc/x86_64-redhat-linux/4.1.1/libstdc++.a
./gcc/x86_64-redhat-linux/4.1.1/32/libstdc++.a
./gcc/x86_64-redhat-linux/4.1.1/32/libstdc++.so
./gcc/x86_64-redhat-linux/4.1.1/libstdc++.so
./libstdc++.so.6
./libstdc++.so.5.0.7
./libstdc++.so.6.0.8
./libstdc++-libc6.2-2.so.3

Thanks in advance!

May 27 '07 #2
On May 26, 9:57 pm, Salt_Peter <pj_h...@yahoo.comwrote:
On May 26, 8:47 pm, "JShra...@gmail.com" <JShra...@gmail.comwrote:
I just upgraded my server to a recent version of redhat, and now old
code no longer compiles. I'm not a C++ coder, but C++ coders who use
my server are now complaining. Here's an example:
#include <iostream>
#include <list>
#include <string>
using namespace std;
template<typename T>
void writeList(const list<T>& alist, const string& separator = " ")
{

// the following is a dependant type.
list<T>::const_iterator iter;

// fix:
typename list<T>::const_iterator iter;
for(iter = alist.begin(); iter != alist.end(); iter++)
cout << *iter << separator;
cout << endl;
}
int main()
{
return 0;
}
And I get this error:
t1.cpp: In function âvoid writeList(const std::list<T,
std::allocator<_CharT&, const std::string\
&)â:
t1.cpp:11: error: expected `;' before âiterâ
t1.cpp:12: error: âiterâ was not declared in this scope
The user who gave me this example claims that STD lib is somehow not
installed correctly on the new server, but I can't figure out what I
could install additionally. My (completely naive) guess is that his
code is deprecated.

The code is deprecated but considering how long dependant types have
been ignored, its really not his fault. You might consider suggesting
that he look up the use of 'typename' in the context of dependant
types. Yours is a classic example.
Here's what I can find that might be relevant:
$ cd /usr/lib
$ find . -print | grep libstd
./libstdc++.so.5
./libstdc++-3-libc6.2-2-2.10.0.so
./gcc/x86_64-redhat-linux/4.1.1/libstdc++.a
./gcc/x86_64-redhat-linux/4.1.1/32/libstdc++.a
./gcc/x86_64-redhat-linux/4.1.1/32/libstdc++.so
./gcc/x86_64-redhat-linux/4.1.1/libstdc++.so
./libstdc++.so.6
./libstdc++.so.5.0.7
./libstdc++.so.6.0.8
./libstdc++-libc6.2-2.so.3
Thanks in advance!
GOOD ONE. "typename" is used to clarify that const_iterator is a type
defined within class list<T>. I tried
JShrager's code on my fedora 4, the same error produced.

May 27 '07 #3
In article <11*********************@o11g2000prd.googlegroups. com>,
JS******@gmail.com says...
I just upgraded my server to a recent version of redhat, and now old
code no longer compiles. I'm not a C++ coder, but C++ coders who use
my server are now complaining. Here's an example:

#include <iostream>
#include <list>
#include <string>

using namespace std;

template<typename T>
void writeList(const list<T>& alist, const string& separator = " ")
{
list<T>::const_iterator iter;
list<T>::const_iterator is a dependent type -- it depends on a template
parameter (T, in this case). Older compilers incorrectly accepted code
like this, but (most) more recent ones correctly require that you tell
them this is intended to be the name of a type:

typename list<T>::const_iterator iter;
for(iter = alist.begin(); iter != alist.end(); iter++)
cout << *iter << separator;
Just FWIW, your loop appears equivalent to:

std::copy(alist.begin(), alist.end(),
std::ostream_iterator<T>(cout, " "));

--
Later,
Jerry.

The universe is a figment of its own imagination.
May 28 '07 #4
list<T>::const_iterator iter;
>
list<T>::const_iterator is a dependent type -- it depends on a template
parameter (T, in this case). Older compilers incorrectly accepted code
like this, but (most) more recent ones correctly require that you tell
them this is intended to be the name of a type:

typename list<T>::const_iterator iter;
Thanks! (And thanks to the others who replied to this.) I passed on
your adivce to the user who wrote the code, and he has (I think) got
things working now.
for(iter = alist.begin(); iter != alist.end(); iter++)
cout << *iter << separator;

Just FWIW, your loop appears equivalent to:

std::copy(alist.begin(), alist.end(),
std::ostream_iterator<T>(cout, " "));
Ain't my loop, but thanks! :-)
May 29 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
by: Robin Becker | last post by:
It seems that the rotor module is being deprecated in 2.3, but there doesn't seem to be an obvious alternative. I'm using it just for obfuscation. It seems we have ssl available in 2.3 for sockets,...
12
by: zhi | last post by:
Really confused, when I use keyword style argument as following: >>> input(prompt="hello") Traceback (most recent call last): File "<pyshell#52>", line 1, in -toplevel- input(prompt="hello")...
23
by: David Frank | last post by:
How can I write a string function that encloses the input string in quotes "string" ?? below works for the "123 operation but adding " to it clobbers the "123 main() { char...
7
by: TeamHubbell | last post by:
Hello, I was wondering if anyone has some suggestions on how to deprecate C routines from a n already released API. I would like to be able to do this via the gcc compiler and be warn the end...
2
by: Bill Nguyen | last post by:
I would like to add a new VB.NET project using the same folder being used by another project so that I can share several forms already creaded by the other project. However, .NET created a new...
185
by: Martin Jørgensen | last post by:
Hi, Consider: ------------ char stringinput ..bla. bla. bla. do {
1
by: psreddy71 | last post by:
i am trying to solve deprecation warning problem from past days.can any body help me please ? i am getting deprecation warning at method .can any body compile this program under jdk1.5 and...
4
by: Anoop | last post by:
Hi All, I am getting the following error while trying to use deprecation Please help 'a.b.mpilgrim.z' Traceback (most recent call last): File "<interactive input>", line 1, in ?...
21
by: Anton Dec | last post by:
Just curious about this... malloc is defined in stdlib.h, right? But if I write a program without #include<stdlib.hand use malloc, it still works as expected. Why is this? Is malloc...
1
by: Gennaro Prota | last post by:
James Kanze wrote: I see. You imply that, in theory, it couldn't be canceled? Or that it would require some long workflow? Yes, I know the etymology (BTW, terms of direct Latin derivation...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.