LWN.net Logo

Russell: GCC and C vs C++ Speed, Measured

Russell: GCC and C vs C++ Speed, Measured

Posted Mar 24, 2013 9:29 UTC (Sun) by aleXXX (subscriber, #2742)
In reply to: Russell: GCC and C vs C++ Speed, Measured by khim
Parent article: Russell: GCC and C vs C++ Speed, Measured

What does --enable-build-with-cxx actually do ?

I mean, even if I do "g++ main.c", main.c is still considered a C file and sizeof('a') should still be 1.
Or does that forcce cxx as a language on all C files ?

Alex


(Log in to post comments)

Russell: GCC and C vs C++ Speed, Measured

Posted Mar 24, 2013 12:46 UTC (Sun) by jwakely (subscriber, #60262) [Link]

> What does --enable-build-with-cxx actually do ?

Approximately, it does CC=g++

> I mean, even if I do "g++ main.c", main.c is still considered a C file and sizeof('a') should still be 1.

I assume you mean sizeof('a') should be 4 if it was considered a C file, but it isn't, using g++ implies the input file is C++

Russell: GCC and C vs C++ Speed, Measured

Posted Mar 26, 2013 10:48 UTC (Tue) by khim (subscriber, #9252) [Link]

I mean, even if I do "g++ main.c", main.c is still considered a C file and sizeof('a') should still be 1.

Rilly? It's easy to test, you know.

$ cat main.c
#include <stdio.h>

int main() {
  printf("%zd\n", sizeof 'a');
  return 0;
}
$ gcc main.c -o main ; ./main
4
$ g++ main.c -o main ; ./main
1

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds