LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-21-2003, 09:03 PM   #1
Pisces107
Member
 
Registered: Dec 2003
Distribution: Slackware Current, Gentoo , Debian SID
Posts: 90

Rep: Reputation: 15
Problem with C++ include/header files!


hi,

i'm new to linux and new to C++ programming. i'm used to Borland C++ 5, Bloodshed's Dev-C on Windows platform.

I have RH 9 and going to install Slack. i have Anjuta for C++ on RH 9. the problem i have is withthe header files of C++; i used to use "iostream, stdio and conio " etc in Windows tools. but when itried using isostream, for example, in the linux (dev tool is Anjuta, and even gcc), i get errors not finding "iostream/iostream.h" . where are those header files ?where have they gone (orthey are still right under my nose but couldn't find'em)?

1. how do i use the header files in linux development tools?

2. is there any document which tells me what all header files are and how to use them in linux?

3. and what other IDEs are available in linux, which are easy to use for newbie programmers/

thanks.
 
Old 12-21-2003, 10:05 PM   #2
CamelofCamelot
Member
 
Registered: Aug 2003
Distribution: Slackware, ClusterKnoppix, Gentoo
Posts: 85

Rep: Reputation: 15
Ok...I'm a slack user, but gcc oughta be the same either way, so:...

gcc likes you to include the C++ headers, not the C headers, ie #include <iostream> not <iostream.h> and soforth, although I don't think this is your problem. 'cause you said you tried both anyway.

and if you're compiling a c++ program, the command would be g++, not gcc, so it'd be like this:
g++ -o ./myprog ./myprog.cpp

and if you're using some wierd library, it might require extra optiony dealies on the end of the g++ cmd dealy. Like alsa likes you to do g++ -o ./prog ./prog.cpp -lalsa (methinks this is right, although I might be thinking of allegro.)

On the IDEs:...
Mostly with Linux, you'll just use a text editor, and save your file as camelprogram.cpp or whatever, and then compile it in the shell with gcc or g++. For text editors w/ good syntax hilighting, I'd try Nedit.

http://www.nedit.org

There's also KWrite's cpp editor dealy, which should already be on your comp, but it seems like hte syntax hilighting only works like half the time. Although I never bothered to try to correct this in any way.

Last edited by CamelofCamelot; 12-21-2003 at 10:09 PM.
 
Old 12-21-2003, 10:10 PM   #3
teval
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Gentoo
Posts: 720

Rep: Reputation: 30
The power of gcc is that it's the allmost the same all over
Instead of
#include "iostream/iostream.h"
Use
#include <iostream>

Header files are mostly the same, except there is no .h usually. It's because the ANSI C++ standard changed a few years ago, and Windows isn't up to date.

There are a few IDEs, eclipse, anjuta, kdevelop I think are the more advanced ones.
Of course there is emacs, xemacs, vi, but those take some getting used to.
 
Old 12-22-2003, 08:27 AM   #4
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Quote:
It's because the ANSI C++ standard changed a few years ago, and Windows isn't up to date.
Ummm... Yeah.... The problem with this statement is that:

1) The OS has absolutely nothing to do with what headers are included with your compiler.
2) Most of the major Windows compilers do allow for the new C++ header standards. (Including Visual C++ 6.0 and above, Borland C++ Builder, Cygwin, etc.)
 
Old 12-22-2003, 08:35 AM   #5
teval
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Gentoo
Posts: 720

Rep: Reputation: 30
Sorry about that,
The only compiler I've ever used on Windows was .. VC, so I automatically associated everyhting with it. When I used it, it wouldn't allow for the new headers at all.
 
Old 12-22-2003, 08:45 AM   #6
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
No problem, It must have been an older version of VC then. 6.0 and .Net both allow the new headers. It's been a long time since I used 5.0 so that maybe didn't, but that's going back far enough that it possibly pre-dates the new ANSI standard, or came out not long after it was established.

I know Turbo C++ didn't allow the new headers, but that is REALLY getting old.
 
Old 12-22-2003, 08:40 PM   #7
Pisces107
Member
 
Registered: Dec 2003
Distribution: Slackware Current, Gentoo , Debian SID
Posts: 90

Original Poster
Rep: Reputation: 15
i'm using anjuta and downloaded the nedit ...so will give it a try.
thanks guys.
 
Old 12-23-2003, 01:52 PM   #8
teval
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Gentoo
Posts: 720

Rep: Reputation: 30
I really want a copy of the ANSI standard right now. I'm curious as to who is breaking it, gcc or VC. One of them is doing ugly things to it, I'm biased twoards saying it's VC, so I want to look it up.
I have to find a copy of it, they only sell hardcopies.. for money.
 
Old 12-23-2003, 02:44 PM   #9
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Umm... if you are still talking about the new header standards, the following compiles and works fine with g++, VC++ 6.0 and VC++ .Net...

Code:
#include <iostream>

using namespace std;

int main()
{
     cout << "Hello world!" << endl;
     return 0;
}
None of the compilers I mentioned breaks that standard...

Also, I was at TechEd this last summer, and one of the things that MS was real proud of was the fact that their 2003 version of VC++ .Net is somewhere around 97% ANSI compliant, whereas g++ was around 96%, and VC++ was 70-something%. I forget the exact numbers, or the website of the group who had performed the tests, but I think it was something like that.

Granted, it was Microsoft saying this, so you need to take it with a grain of salt, but still... They did actually make some progress towards making their latest compiler more ANSI compliant.

Also, just for reference, there is a link to the C++ ANSI standards that you can look at Here

Last edited by deiussum; 12-23-2003 at 02:46 PM.
 
Old 12-23-2003, 02:58 PM   #10
clockworks
Member
 
Registered: Dec 2003
Location: texas
Distribution: fedora core 1, fedora core 2
Posts: 37

Rep: Reputation: 15
uhh, both gcc (g++) and VC do not adhere to the standards.

examples?

in VC...
Code:
for (int i = 0; i < 10; ++i)
	//do something
// i is still defined here, i.e. it doesn't go out of scope with the ending of the for loop
in g++
Code:
// non standard way to init structs
struct Blah blah = { 10, "blah", 9.99 };
// i acctually forget the exact syntax
both g++ and VC do not allow for seperate compilation of templatized classes even though its in the standard.

-- C

p.s. the last time i used VC was 3-4 years ago and it was VC 6.0.
 
Old 12-23-2003, 03:44 PM   #11
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
I don't think any compiler FULLY adheres to the ANSI standards, and I never claimed they did. For the header example noted here, though, most current compilers do comply...

Also, In your scoping example for VC++.... That is one of the things they fixed in the .Net version of VC++. That was one of the annoying things to me about writing code for VC++ 6.0 and the gnu compiler. You had to define it outside the for loop in order to use the same variable in 2 separate for loops. I was glad that was fixed.


Actually, I should qualify the above statement about the scoping. It still doesn't FULLY comply with that standard. For instance, you can do this in both the 6.0 and .Net versions of VC++:

Code:
for (int i=0;i<10;i++)
{
    cout << i << endl;
}

cout << i << endl;
However, the following code will give you an error in VC++ 6.0 and not .Net. (Variable already defined or some such...)

Code:
for (int i=0;i<10;i++)
{
    cout << i << endl;
}

for (int i=0;i<10;i++)
{
    cout << i << endl;
}

Last edited by deiussum; 12-23-2003 at 03:54 PM.
 
Old 12-23-2003, 09:21 PM   #12
teval
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Gentoo
Posts: 720

Rep: Reputation: 30
for (int i=0;i<10;i++)
{
cout << i << endl;
}

cout << i << endl;

That's not very good code. There are dozens of ways to do that without resorting to thigns like that. There are very good reasons why it goes out of scope, most importantly to allow us to reuse things like i, which simply aren't descriptive enough to be reused. I don't think I've ever encountered a problem in any programming language similar to this one that couldn't easily be solved in a better way. Go ANSI!
 
Old 12-23-2003, 11:06 PM   #13
clockworks
Member
 
Registered: Dec 2003
Location: texas
Distribution: fedora core 1, fedora core 2
Posts: 37

Rep: Reputation: 15
Quote:
Originally posted by deiussum
I don't think any compiler FULLY adheres to the ANSI standards, and I never claimed they did.
nod, i thought you said "the" when you really said "that". context: they do adhere to >that< standard.

-- C
 
  


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
Kernel header (include) files - where do i find these walkerx Mandriva 2 04-17-2005 08:19 AM
Include Custom Header Kenji Miyamoto Programming 3 01-13-2005 08:46 PM
header include path KDE4me Linux - Newbie 6 01-06-2005 06:17 AM
c header files in linux in place of header files in windows? harun_acs Programming 1 03-17-2004 02:24 AM
need perl fuction like c #include statement for header file mrtwice Programming 5 06-19-2003 02:42 PM

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

All times are GMT -5. The time now is 01:06 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