ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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'.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.