Deutsch English Français Italiano |
<20240526180531.00007259@yahoo.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Michael S <already5chosen@yahoo.com> Newsgroups: comp.lang.c Subject: Re: C23 thoughts and opinions Date: Sun, 26 May 2024 18:05:31 +0300 Organization: A noiseless patient Spider Lines: 131 Message-ID: <20240526180531.00007259@yahoo.com> References: <v2l828$18v7f$1@dont-email.me> <v2o57g$1t5p4$1@raubtier-asyl.eternal-september.org> <7d0e8f25-a8ba-4995-9b90-ff35f85d423f@gmail.com> <v2p91e$26lpk$1@raubtier-asyl.eternal-september.org> <beffc569-3606-b627-ded9-93ce8478f2dd@please.ty> <20240525142325.517@kylheku.com> <v2ul1f$3aa7c$1@dont-email.me> <871q5o29af.fsf@nosuchdomain.example.com> <v2v7av$3d561$1@dont-email.me> <20240526153913.00007f65@yahoo.com> <v2vefo$3e72q$1@dont-email.me> <v2vh0f$3eaba$3@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Date: Sun, 26 May 2024 17:05:22 +0200 (CEST) Injection-Info: dont-email.me; posting-host="748cc89cfd4b455fba2588d67f703cb1"; logging-data="3503865"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+oJcThikZTSLiaJIBQUpGuuAdlXHeBQA8=" Cancel-Lock: sha1:d/08BEUOS+TitZZPDNv0risHvL8= X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32) Bytes: 6274 On Sun, 26 May 2024 16:29:35 +0200 David Brown <david.brown@hesbynett.no> wrote: > On 26/05/2024 15:46, jak wrote: > > Michael S ha scritto: =20 > >> On Sun, 26 May 2024 13:44:32 +0200 > >> jak <nospam@please.ty> wrote: > >> =20 > >>> Keith Thompson ha scritto: =20 > >>>> jak <nospam@please.ty> writes: =20 > >>>>> Kaz Kylheku ha scritto: =20 > >>>>>> On 2024-05-24, jak <nospam@please.ty> wrote: =20 > >>>>>>> Bonita Montero ha scritto: =20 > >>>>>>>> Am 23.05.2024 um 21:49 schrieb Thiago Adams: =20 > >>>>>>>>> On 23/05/2024 16:25, Bonita Montero wrote: =20 > >>>>>>>>>> I ask myself what the point is in further developing a > >>>>>>>>>> language like this that can actually no longer be saved. =20 > >>>>>>>>> do you mean C++? =20 > >>>>>>>> > >>>>>>>> No, C. =20 > >>>>>>> > >>>>>>> I think you have a lot of confusion about programming > >>>>>>> languages. C and C++ are not comparable languages. =20 > >>>>>> Except for observations like that we can write useful, > >>>>>> production software that compiles as C or C++, but go on ... =20 > >>>>> > >>>>> 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. =20 > >>>> > >>>> Oh?=C2=A0 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.=C2=A0 How would a compiler that behaves as you > >>>> describe cope with that? =20 > >>> > >>> 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++. > >>> =20 >=20 > No. >=20 > >> > >> No, it does not. > >> g++ compiles as C++ unless you tell it to compile as C with '-x c' > >> option. > >> =20 >=20 > No. >=20 > >> > >> =20 > >=20 > > 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. > > =20 >=20 > No. >=20 >=20 > The way gcc handles all this is actually quite straightforward. >=20 > First, there is no difference between the commands "gcc" and "g++" in=20 > the languages supported, or the way the language is determined. The=20 > only difference between these two is the standard libraries linked by=20 > default when generating a final executable - "g++" automatically=20 > includes the C++ standard libraries, while "gcc" only has the C > standard libraries. >=20 > In neither case does "gcc" or "g++" actually handle the compilation -=20 > these are driver front-ends that pass things on to the actual > compilers, assemblers and linkers (and any other bits and pieces > required). >=20 I don't know how it works in your environment. 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.exe 'gcc -c foo.c' calls binary cc1.exe 'gcc -c foo.cpp' calls binary cc1plus.exe 'gcc -c foo.C' calls binary cc1plus.exe > The front-ends determine the language to use primarily from the > 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 my environment it applies to gcc, but not to g++. 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, such > as "-x c" or "-x c++". The standard can be specified with "-std=3D". > Yes, of course. > There is no automatic detection of C or C++ based on the /content/ of=20 > the files. >=20 Yes, of course. >=20 > <https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html> >=20