News for hackers. Stuff that matters.
Re:C, Fortran, and single-character strings by verisimilitudes on Friday June 21, 2019 @11:37PM (#20247871)
>This is not a language issue, but programmers who have made a mistake.

That's always the excuse with C, I know.

>The same thing would happen in most languages if a programmer declared their FFI incorrectly.

If the Ada Interfaces.Fortran didn't work, that would be a compiler issue, but that's only because Ada does things right.

>It boils down to some programmer/s doing the following.

I read the article, you know.

Re:C, Fortran, and single-character strings by anfilt on Saturday June 22, 2019 @01:19AM (#20248164)
You can do the same thing in ada. Instead of using the Fortran_Character type defined in Interfaces.Fortran you could just define your own that does not follow Fortran's string calling convention.

Is that a language problem with ada? That's all the C programmers did here.

Re:C, Fortran, and single-character strings by verisimilitudes on Saturday June 22, 2019 @03:11AM (#20248406)
>You can do the same thing in ada.

I wouldn't know how GNAT behaves in this case, but I figure it would at the least be much harder to do by mistake, as has been done with C for years.

>Instead of using the Fortran_Character type defined in Interfaces.Fortran you could just define your own that does not follow Fortran's string calling convention.

The Ada compiler is aware of what's being done when you interface with another language. You must tell it how the procedure is from a different language and you're also able to specify the representation of Ada data types to conform. I wouldn't be surprised to learn that GNAT is capable of checking on the Fortran side of things as well, for interfacing like this.

>Is that a language problem with ada? That's all the C programmers did here.

I don't believe Ada has this issue, but I'd wager it at the least makes it harder to make. In any case, I have no personal experience interfacing Ada with Fortran.

My point, however, is that this is a very common issue with C programming, where people don't know what they're doing and things break constantly. The C language is not designed for interfacing with other languages, in part because it wasn't designed much at all.

Re:C, Fortran, and single-character strings by rightbyte on Saturday June 22, 2019 @09:14AM (#20249428)
Calling conventions are ... conventions. What language magically solves inter architecture ABIs?
Re:C, Fortran, and single-character strings by icedchai on Saturday June 22, 2019 @11:36PM (#20253160)
Given how many other languages interface with C (basically, all of them), this statement is a bit silly and clearly false.