|
|
|
|
![]() ![]() |
May 23 2007, 03:30 PM
Post
#1
|
|
|
Way Out Of Control - You need a life :) Group: [MODERATOR] Posts: 1,969 Joined: 16-August 05 Member No.: 7,896 |
If you already had the same problem I just experienced, you should probably be interested by this trick.
I just installed a compiler, and I wanted to know if I installed the C and the C++ compiler, or only the C compiler. The answer is simple : let's use small sample programs. Everybody know the well-known "hello" world C program, it compiles with a standard C compiler. CODE main () { printf("Hi, Folks, what s new"); } And here is a sample C++ "hello world" program : CODE #include <iostream.h> main() { cout << "Hello World!"; return 0; } The second sample program compiles only with a C++ compiler, the standard C compiler gives an error for the "cout" syntax. So, using these two small pieces of code allows you to check that you have both the standard C and the C++ compilers. Hope this helps you as it helped me. Regards Yordan
Reason for edit: HTML tags in CODE block
|
|
|
|
May 23 2007, 10:48 PM
Post
#2
|
|
|
Way Out Of Control - You need a life :) Group: Members Posts: 1,086 Joined: 21-June 05 From: New York Member No.: 6,440 |
Haven't used those compilers that were meant only for C or only for C++. The ones I tried usually compiles both, but that's definitely a good thing to know. Even Borland's Turbo C++ (name implies that it's a C++ compiler) works with the C language
|
|
|
|
May 24 2007, 02:57 AM
Post
#3
|
|
|
PsYcheDeLiC dR3aMeR Group: Admin Posts: 2,242 Joined: 29-January 05 From: Nakorn Chaisri, Thailand Member No.: 2,411 |
Haven't used those compilers that were meant only for C or only for C++. The ones I tried usually compiles both, but that's definitely a good thing to know. Even Borland's Turbo C++ (name implies that it's a C++ compiler) works with the C language Yep - all C++ compilers are supposed to be backward compatible, i.e. be able to compile C code as well. That is a standardised rule. |
|
|
|
May 24 2007, 01:35 PM
Post
#4
|
|
|
Way Out Of Control - You need a life :) Group: [MODERATOR] Posts: 1,969 Joined: 16-August 05 Member No.: 7,896 |
Yep - all C++ compilers are supposed to be backward compatible, i.e. be able to compile C code as well. That is a standardised rule. Yes, and the trap is that C-only compilers won't compile C++ programs. So, if you prepare a system for somebody else, you should better verify it before calling your collegue, or you will have to pay an apologizing beer. By the way, I wrote this in the "How-To's" section, because there is no "Tricks and Tips" section. This post has been edited by yordan: May 24 2007, 01:37 PM |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 21st August 2008 - 11:15 PM |