Intel Fortran has a notation to specify C string literals by appending the
letter C at the end of the string. See here for an example:
http://www.intel.com/software/products/compilers/docs/flin/main_for/mergedProjects/lref_for/source_files/pgcchcs.htm

It would be nice to have this, or something similar, in gfortran.

With Intel Fortran, it causes the string to interpret backslash sequences as in
C, and append a NUL character. I suggested to Intel the idea of implementing a
.C. unary string operator to do the same thing (I had seen it suggested on
c.l.f.), with the idea of trying to fit extensions into vendor intrinsic
modules instead of the traditional non-standard syntax approach. They said it
would be less standard-conforming, maybe because defined-unary operators cannot
be used in initialization expressions. They also stated that the C-suffix
approach was a well-establish extension, although neither gfortran nor Sun have
it.

I am requesting that gfortran support Intel's C-string notation to improve the
portability of C-interop code, if you think the extension is reasonable. It
would be nice for Fortran compiler developers to agree on some other common
convention, no matter what it is. One negative aspect of Intel's notation is
that it would be good to support C escape sequences independent of the NUL
terminator.

FYI: I also suggested that they look into gfortran's work on implementing new
character kinds such as UTF-8. That will also be very useful for reliable C
interop.


-- 
           Summary: Request for C string literal syntax
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jkrahn at nc dot rr dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37224

Reply via email to