| Deutsch English Français Italiano |
|
<vm7n1a$2rr87$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Thomas Koenig <tkoenig@netcologne.de>
Newsgroups: comp.lang.fortran
Subject: Re: nasty link problem with Gfortran and G++ (C++) ???
Date: Wed, 15 Jan 2025 07:10:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <vm7n1a$2rr87$2@dont-email.me>
References: <vlk6nb$2cmk4$1@dont-email.me> <vm4qvh$29grr$2@dont-email.me>
<vm6b6p$2hekc$1@dont-email.me> <vm73r5$2lla3$1@dont-email.me>
Injection-Date: Wed, 15 Jan 2025 08:10:34 +0100 (CET)
Injection-Info: dont-email.me; posting-host="50e220f903c675653f4149ac224e3dfa";
logging-data="3009799"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gKqbA+b/ZN5+ErvJU2CN3Pmxx0v1dwhs="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:/YFSWiA+tgx5hyzO/MouGkb8YEQ=
Bytes: 2187
Lynn McGuire <lynnmcguire5@gmail.com> schrieb:
> On 1/14/2025 12:42 PM, Thomas Koenig wrote:
>> Lynn McGuire <lynnmcguire5@gmail.com> schrieb:
>>
>>> I found and fixed the problem with my code along with one of my
>>> programmers. I was not properly handling the size_t hidden argument
>>> length value that GFortran adds to the character string arguments in my
>>> C++ code. Things are going better now.
>>
>> Good to hear that.
>>
>> Another thing that works well for gcc is to link everything with
>> the -flto option.
>>
>> An example:
>>
>> $ cat main.f90
>> program memain
>> character *1 c
>> call foo(c)
>> print *,c
>> end
>> $ cat foo.c
>> void foo_(char *c)
>> {
>> *c = 'A';
>> }
>> $ gfortran -flto main.f90 foo.c
>> main.f90:3:13: warning: type of 'foo' does not match original declaration [-Wlto-type-mismatch]
>> 3 | call foo(c)
>> | ^
>> foo.c:1:6: note: type mismatch in parameter 2
>> 1 | void foo_(char *c)
>> | ^
>> foo.c:1:6: note: type 'void' should match type 'long int'
>> foo.c:1:6: note: 'foo_' was previously declared here
>
> I will try it.
Just a warning - be prepared for loooong compile times.