pradyun/Py2C

Clarify that you mean C++

KarjamP opened this issue · 1 comments

A common mistake is to say C/C++ when you talk about these two languages.

Not only is this correct, it also implies that they're the same language (they're not).

For example, the sample code you've posted on the main page (the hello world program converted to C++) can't compile on C because it doesn't support the << operator (it only supports printf).

Not only that, in addition to the futures that were introduced in C++ only existing in that language (ie, classes, templates, exception handling, etc.), there's certain code that would compile on C but not on C++, like this:

int main()
    {
        double sq2 = sqrt(2);   /* Not C++: call undeclared function */
        int s = sizeof('a');    /* silent difference: 1 in C++ sizeof(int) in C */
    }

And this:

void* malloc(size_t);

void f(int n)
{
    int* p = malloc(n*sizeof(char));  /* not C++. In C++, allocate using `new' */
    char c;
    void* pv = &c;
    int* pi = pv;   /* implicit conversion of void* to int*. Not in C++ */
}

(both are taken from Stroustrup (the original designer of C++)'s website.)

Sources:

http://www.stroustrup.com/bs_faq.html#C-is-subset

http://www.stroustrup.com/bs_faq.html#C-slash

Thanks, actually when "C/C++" is used, I meant C or C++. I had wrote that in a very early planning stage. Now we have decided we are targeting C++.