LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-15-2003, 07:05 PM   #1
G67
LQ Newbie
 
Registered: Dec 2003
Posts: 23

Rep: Reputation: 15
c++ and stl


hey, i had code compiled with gcc 2.x previously. Now the same code wont compile with the new gcc 3.x lib's. ??

the command i am using compile is
g++ -I ./stl/ program.cpp -o program

in addition programs that dont use STL give me some warnings about backwards compatibility.

How do i compile my older c++ programs using stl in gcc 3.x?
 
Old 12-15-2003, 07:28 PM   #2
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 46
what are the errors u get while compiling?
 
Old 12-16-2003, 05:23 PM   #3
dakensta
Member
 
Registered: Jun 2003
Location: SEUK
Distribution: Debian & OS X
Posts: 194

Rep: Reputation: 35
Are you using:
#include <headerfile.h> ?

if so, change this to:
#include <headerfile>

and either
1) qualify containers etc. with "std::container" when used
or
2) call "using std::container;"
3) call "using namespace std;"
before you use them.

Code:
#include <iostream>
int main()
{
std::cout << "Hello World" << std::endl;
}
or
Code:
#include <iostream>
int main()
{
using std::cout;
using std::endl;
// or using namespace std; for the lot
cout << "Hello World" << endl;
}

Last edited by dakensta; 12-16-2003 at 05:25 PM.
 
Old 12-17-2003, 02:21 AM   #4
G67
LQ Newbie
 
Registered: Dec 2003
Posts: 23

Original Poster
Rep: Reputation: 15
hi, thanks for the help, it worked.
I noticed a similar post after i posted mine, and i got some of the answers in there.

why did they make these changes?
was it not just easier to use cout instead of std::cout?

Thanks for help though.
 
Old 12-17-2003, 02:36 AM   #5
chens_83
Member
 
Registered: Dec 2001
Location: Adelaide , South Australia
Distribution: redhat 7.2, Debian , OpenBSD
Posts: 123

Rep: Reputation: 15
Code:
using namespace std;
will automatically be put in for you.

Alot of the alien style warnings that it gives are things that the compiler is doing for you. Really hard to get rid of them, because you have to know what to look for.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
about STL programming wangjinyi Programming 2 03-24-2005 05:45 PM
Are the QT suuport STL? Barq Linux - General 1 11-18-2004 10:20 AM
Stl iterator woes Config Programming 4 06-23-2004 05:31 PM
stl containers champ Programming 2 04-09-2003 05:27 AM
C++ STL problem jaycee999 Programming 5 05-31-2002 03:01 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration