Liste des Groupes | Revenir à cl c |
On Sun, 26 May 2024 16:29:35 +0200My apologies - you are correct.
David Brown <david.brown@hesbynett.no> wrote:
On 26/05/2024 15:46, jak wrote:I don't know how it works in your environment.Michael S ha scritto:>On Sun, 26 May 2024 13:44:32 +0200
jak <nospam@please.ty> wrote:
Keith Thompson ha scritto:jak <nospam@please.ty> writes:>Kaz Kylheku ha scritto:>On 2024-05-24, jak <nospam@please.ty> wrote:>Bonita Montero ha scritto:Except for observations like that we can write useful,Am 23.05.2024 um 21:49 schrieb Thiago Adams:>On 23/05/2024 16:25, Bonita Montero wrote:>I ask myself what the point is in further developing ado you mean C++?
language like this that can actually no longer be saved.
No, C.
I think you have a lot of confusion about programming
languages. C and C++ are not comparable languages.
production software that compiles as C or C++, but go on ...
Indeed there are c++ compilers who, if used to compile c code,
could decide to call the c compiler to do the work, but if
something in the code is not strictly c, then the compilation
will be in c++, the size of the executable will increase
significantly and will need of an internal or external runtimer
to work. If it were the same thing you would not get different
things.
Oh? Do you know of a C++ compiler that actually behaves this
way? I've never heard of such a thing.
>
C and C++ are closely related, and C and C++ compilers often
share backends, but the two languages have different grammars.
The gcc command, for example, can invoke either a C or C++
compiler, but it knows which language it's compiling based on
the source file name or command line options, before it's even
seen the content.
>
There are programs that are valid C and valid C++ but with
different behavior. How would a compiler that behaves as you
describe cope with that?
For example g++ makes something similar: if you pass a file .C it
compile the C code but if the file (.C) contains C++ code then
compile C++.
No.
>>>
No, it does not.
g++ compiles as C++ unless you tell it to compile as C with '-x c'
option.
No.
>>>>
You didn't read carefully or I didn't express myself well. I wrote
that the g++ compile c++ even if it is written inside a .c file.
However in doubt I preferred to try. If I pass to g++ a .c file that
contains c code, it compiles without any option, perhaps because it
reads as if it were c++ but in any case compiles it.
No.
>
>
The way gcc handles all this is actually quite straightforward.
>
First, there is no difference between the commands "gcc" and "g++" in
the languages supported, or the way the language is determined. The
only difference between these two is the standard libraries linked by
default when generating a final executable - "g++" automatically
includes the C++ standard libraries, while "gcc" only has the C
standard libraries.
>
In neither case does "gcc" or "g++" actually handle the compilation -
these are driver front-ends that pass things on to the actual
compilers, assemblers and linkers (and any other bits and pieces
required).
>
I am 100% sure that it works like I wrote above in my environment.
Specifically:
'g++ -c foo.c' calls binary cc1plus.exe
'g++ -c -x c foo.c' calls binary cc1.exeYes, of course.
'gcc -c foo.c' calls binary cc1.exe
'gcc -c foo.cpp' calls binary cc1plus.exe
'gcc -c foo.C' calls binary cc1plus.exe
No, g++ treats extensions other than ".c" the same way as gcc. (I tested to be sure this time!) Try :The front-ends determine the language to use primarily from theIn my environment it applies to gcc, but not to g++.
suffix of the source file it is given. ".c" files are compiled as C.
".cpp", ".c++", ".cc", ".C" (note the capital C), ".cp", ".cxx", and
".CPP" are compiled as C++. (There are many other extensions
supported for different languages.)
>
In order to force my g++ to compile for other language you have to tell
it so explicitly.
The language choice can be overridden by using the "-x" switch, suchYes, of course.
as "-x c" or "-x c++". The standard can be specified with "-std=".
>
There is no automatic detection of C or C++ based on the /content/ ofYes, of course.
the files.
>
>
<https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html>
>
Les messages affichés proviennent d'usenet.