C, Fortran, and single-character strings
C, Fortran, and single-character strings
Posted Jun 22, 2019 21:37 UTC (Sat) by ncm (guest, #165)In reply to: C, Fortran, and single-character strings by nivedita76
Parent article: C, Fortran, and single-character strings
To pass an integer that is to be interpreted as an enumeration value, you also pass just a pointer. In Fortran, enumeration values are conventionally assigned character codes. They're not strings, they're just convenient literal notation for a symbol. Passing a pointer to a character is just the language idiom for an enumerated-value argument.
But passing a pointer to a character is not wrong or fragile code. Changing a library to fail without an extra length argument, after conventional usage is well-established, would be. If, in fact, maintainers of Fortran libraries are doing that, shame on THEM. I see no reason for C users of Fortran libraries to be embarrassed. Their code is not wrong or fragile, absent specific documentation of the original library to the contrary. Changing the compiler to forbid this usage would be wrong.
If you look at the libraries in question, you will probably find places where an argument interpreted as an enumerator is followed by another actual argument, where inserting another, length, argument would produce the wrong result, or a crash.
Posted Jun 24, 2019 5:47 UTC (Mon)
by joib (subscriber, #8541)
[Link]
C, Fortran, and single-character strings