On Wed, Sep 11, 2002 at 08:30:43PM -0500, Sreangsu Acharyya wrote:
> you have to keep away from c++ specific key words.

Well, even that is NOT true. I admit the first example I posted used C++
specific keywords, but what about this?

binand@binand[~]:(9) cat a.c
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    char *t = malloc (1);
    if (t) free(t);
    return 0;
}

binand@binand[~]:(11) gcc -Wall a.c -o /dev/null
binand@binand[~]:(12) mv a.c a.C
binand@binand[~]:(13) g++ -Wall a.C -o /dev/null
a.C: In function `int main ()':
a.C:5: cannot convert `void *' to `char *' in initialization

As you can see, even a simple program like the above cannot be considered
as both valid C and C++.

> BTW the reverse also works, compiling a cpp program with gcc, if you follow the
> conventional suffixes for src files. It wouldnt link though as gcc by default
> will try to link with the std C library, but you can easily fix that by
> explicitly linking with libstdc++

I don't understand what you are saying here, but please show me the exact steps
you'd take to compile this C++ program under a C compiler:

binand@binand[~]:(20) cat a.C
#include <iostream>

int main (void) {
    cout << "Hello World" << endl;
    return 0;
}

You have to use the command line gcc -x c a.C <more flags>

ie, please demonstrate how you'd compile a C++ program with a purely
C compiler.

Binand

-- 
If you found this helpful, please take some time off to rate it:
http://svcs.affero.net/rm.php?r=binand


-------------------------------------------------------
In remembrance
www.osdn.com/911/
_______________________________________________
linux-india-help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/linux-india-help

Reply via email to