Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c++
Subject: Re: Don't extensions still work? (Was: Trying to be generic with the linker (ld instead of g++))
Date: Thu, 22 Aug 2019 12:57:46 -0700
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <8636ht2csl.fsf@mailhub.linuxsc.com>
References: <864l29ifqm.fsf@mailhub.linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="59398aca864cd103291b848dd2e1e135"; logging-data="9646"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19RcNt0ARq82/izK2aEknRLRHXJUEOF7mE="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:BW91hnVXgmCIWYSnZVShkqJXE34= sha1:PM457NXJ+8Of29g058QI3RfjCvU=
Xref: csiph.com comp.lang.c++:67887
gazelle@shell.xmission.com (Kenny McCormack) writes:
> In article <864l29ifqm.fsf@mailhub.linuxsc.com>,
> Tim Rentsch wrote:
> ...
>
>> Forgive me if this is a dumb question. Is there some reason
>> you have to use gcc in the first step? How about doing this
>> instead:
>>
>> g++ -x c -c *.c
>> g++ -x c++ -c *.cpp
>> g++ -o prog *.o
>>
>> Substituting clang for g++ should also work here. Disclaimer: I
>> haven't verified anything beyond confirming that both g++ and
>> clang accept the -x c and -x c++ options.
>
> I didn't even think you needed the -x option, as long as your
> files have recognized extensions. [...]
For things like C and C++, which have widely recognized ISO
standards, I don't mind taking the established rules as being
authoritative, and acting accordingly.
For tools like gcc or g++ or clang, which depend on the whims of
whichever developers happen to be contributing, and which easily
may change from one version to another, my usual practice is to
spell things out more explicitly. Here I think it helps convey
the point if the -x c and -x c++ options are made explicit rather
than being left as implied.