C_CHAR weird behaviour, arguments function concatenation.
Dennis Wassel
dennis.wassel@googlemail.com
Wed Dec 17 11:59:00 GMT 2008
2008/12/17 Cyril Giraudon <cyril.giraudon@ginkgosolutions.com>:
> Hello,
[snip]
> program say2words
> use FTN_C
> implicit none
>
> integer(kind=C_INT) :: error
>
> print *, "Going to say ..."
> error = say("hello", "boy")
>
> end program say2words
>
> """
I'm not sure if this is supposed to work or even standard-conforming.
You surely know that Fortran, contrary to C, does not null-terminate
strings, and my experience is that the BIND(C) attribute does not
enforce this, either.
What happens if you add it manually like this "hello" // C_NULL_CHAR
(likewise for "boy")?
> Unexpectedly, the output is :
> """
> Going to say ...
> word 1 : hello
> word 2 : boyhello
> """
>
> I don't undestand, word2 is the concatenation of word2 and word1.
> Is there any bug ?
>
> Thanks a lot,
>
> Cyril.
More information about the Fortran
mailing list