LinuxQuestions.org
Review your favorite Linux distribution.
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 01-23-2004, 08:38 PM   #1
dmalsbury
LQ Newbie
 
Registered: Jan 2004
Location: san antonio, tx
Distribution: slackware 9.1
Posts: 15

Rep: Reputation: 0
#include <stdio.h> problem


slackware 9.1 - every time i use

#include <stdio.h>

as the 1st line of my code, I get a page full of errors when I compile with cc, removing it works ok, with no errors.

I thought I needed it. can you help?

newbie Doug Malsbury
 
Old 01-23-2004, 08:42 PM   #2
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 46
gcc?
 
Old 01-23-2004, 08:54 PM   #3
dmalsbury
LQ Newbie
 
Registered: Jan 2004
Location: san antonio, tx
Distribution: slackware 9.1
Posts: 15

Original Poster
Rep: Reputation: 0
should i use cc or gcc or gpp? dont know if that will change my problem though.
 
Old 01-23-2004, 09:02 PM   #4
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 46
see if you get that error with gcc (im thinking you will...)
 
Old 01-23-2004, 09:13 PM   #5
dmalsbury
LQ Newbie
 
Registered: Jan 2004
Location: san antonio, tx
Distribution: slackware 9.1
Posts: 15

Original Poster
Rep: Reputation: 0
i do.
whats the diff btwn cc, gcc, etc?
why does it seem to work w/o the #include?

thanx for your help
Doug
 
Old 01-23-2004, 09:20 PM   #6
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 46
i'm not sure about this, as i havent come across errors with headers in C. can you post the errors that fly by?

also, is it only with stdio.h or any header file?
 
Old 01-24-2004, 12:20 AM   #7
zekko
Member
 
Registered: Aug 2003
Location: Canada
Distribution: Slackware, debian
Posts: 76

Rep: Reputation: 15
Post the errors and maybe the code (if its not too big), I'm sure someone here can help you out.
 
Old 01-24-2004, 01:16 AM   #8
UltimaGuy
Member
 
Registered: Aug 2003
Location: Chennai, India
Distribution: PCLinuxOS .92, FC4
Posts: 840

Rep: Reputation: 32
The 'cc' is the C++ precompiler and using it for C code is bound to cause errors. Try using gcc, and then post the errors here....
 
Old 01-24-2004, 10:37 AM   #9
cjcuk
Member
 
Registered: Dec 2003
Distribution: Openwall, ~LFS
Posts: 128

Rep: Reputation: 15
Quote:
Originally posted by UltimaGuy
The 'cc' is the C++ precompiler and using it for C code is bound to cause errors. Try using gcc, and then post the errors here....
It should not be, you obviously have a strange system setup. `cc' is supposed to be a C Compiler or a symbolic link to the preferred C Compiler for the system. More often than not, `cc' will be a symlink to `gcc'.
 
Old 01-24-2004, 11:28 AM   #10
amos
Member
 
Registered: Dec 2002
Location: Bolton, UK
Distribution: Kubuntu
Posts: 224

Rep: Reputation: 30
If you're compiling a c++ program use: #include <stdio>
but follow it with: using namespace std;
or lots of errors occur.
You can still use #include <stdio.h> and you'll get a warning that its deprecated but everything should work without the need to resort to 'using namespace std;'.

If you're compiling a c++ program invoke the compiler with: g++ myprog.cpp (possibly adding -omyprog, to get an executable called myprog).

'gcc' calls the c compiler part of gcc, 'g++' calls the c++ compiler part.

Cheers
Amos
 
Old 01-24-2004, 01:22 PM   #11
MartinN
Member
 
Registered: Nov 2003
Location: Ronneby, Sweden
Posts: 555

Rep: Reputation: 30
Quote:
Originally posted by amos
If you're compiling a c++ program use: #include <stdio>
but follow it with: using namespace std;
or lots of errors occur.
You can still use #include <stdio.h> and you'll get a warning that its deprecated but everything should work without the need to resort to 'using namespace std;'.

If you're compiling a c++ program invoke the compiler with: g++ myprog.cpp (possibly adding -omyprog, to get an executable called myprog).

'gcc' calls the c compiler part of gcc, 'g++' calls the c++ compiler part.

Cheers
Amos
It's cstdio, not stdio.

Martin
 
Old 01-24-2004, 04:49 PM   #12
amos
Member
 
Registered: Dec 2002
Location: Bolton, UK
Distribution: Kubuntu
Posts: 224

Rep: Reputation: 30
My mistake.

Cheers
Amos
 
Old 01-25-2004, 01:24 AM   #13
UltimaGuy
Member
 
Registered: Aug 2003
Location: Chennai, India
Distribution: PCLinuxOS .92, FC4
Posts: 840

Rep: Reputation: 32
cjcuk, I am not at my system, so I can't check out. But I am pretty sure that in my RH9 box, the 'cc' command on any cpp source file just precompiles it. I've even read something about compilers and know a few flags that I regularly use in my make files. And so I think that 'cc <progname.cpp>' in my box just precompiles the source file and outputs to the console.
 
Old 01-25-2004, 08:55 AM   #14
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
cc should definatly be the preferred C compiler for the system

by the latest Linux From Scratch book
Many packages use the name cc to call the C compiler. To satisfy those packages, create a symlink:

ln -s gcc /usr/bin/cc


the (GNU)C preprocessor is cpp and tends to live in /usr/bin or /usr/lib
 
Old 01-25-2004, 09:05 AM   #15
UltimaGuy
Member
 
Registered: Aug 2003
Location: Chennai, India
Distribution: PCLinuxOS .92, FC4
Posts: 840

Rep: Reputation: 32
Oh, sorry guys. I had created a link to cpp as cc, and I use it quite regularly, so I was confused a bit. I back off with humble apologies....
 
  


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
#include <windows.h> problem blufire Programming 5 11-26-2004 03:58 AM
stdio problem in gcc iansworld Linux - Software 0 10-19-2004 10:12 AM
#include <stdio.h>? blackzone Programming 2 09-30-2004 06:00 AM
gcc on 9.1 include problem skywarp Slackware 3 06-04-2004 10:05 PM
Problem with C++ include/header files! Pisces107 Programming 12 12-23-2003 11:06 PM

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

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