Sujet : Re: nasty link problem with Gfortran and G++ (C++) ???
De : tkoenig (at) *nospam* netcologne.de (Thomas Koenig)
Groupes : comp.lang.fortranDate : 14. Jan 2025, 19:42:34
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vm6b6p$2hekc$1@dont-email.me>
References : 1 2
User-Agent : slrn/1.0.3 (Linux)
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