This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Making gcc 2.9 accept backslash + CR + NL


Hi!

I hope this is the right place to ask my question.
And I wonder how to ask it correctly, so that it gets answered...

I'm trying to port Symbian builds to Linux.
Symbian uses gcc 2.95 (they call it 2.9) under DOS. 
The source code is available at
http://www.symbian.com/developer/development/
and I have been able to compile it on Linux
(see the %build-section in the attached rpm spec).

The compiler works fine except for the problems like this:
epoc32/include/e32std.h:4070: `AType' was not declared in this scope
epoc32/include/e32std.h:4070: `AData' was not declared in this scope
epoc32/include/e32std.h:4070: `AData' was not declared in this scope
epoc32/include/e32std.h:4070: template argument 1 is invalid
epoc32/include/e32std.h:4070: stray '\' in program

I realize, that this is coming from the compiled files
being in DOS text format and thus the \ \r \n not recognized
as a line continuation sequence. For various reasons I need
to keep the source files in the DOS text format and that is
why I'm trying to patch the gcc source code.

Here is my test case (the stray-dos.c is in the DOS format):

bolinux72:gcc {584} cat ~/stray-unix.c 
#define DECLARE_ROM_ARRAY( AName, AData, AType ) \
        const TFixedArray<AType,(sizeof(AData)/sizeof((AData)[0]))>& \
            AName = *(reinterpret_cast<const TFixedArray<AType, \
                           (sizeof(AData)/sizeof((AData)[0]))>* > (AData))

bolinux72:gcc {585} cat ~/stray-dos.c
#define DECLARE_ROM_ARRAY( AName, AData, AType ) \
        const TFixedArray<AType,(sizeof(AData)/sizeof((AData)[0]))>& \
            AName = *(reinterpret_cast<const TFixedArray<AType, \
                           (sizeof(AData)/sizeof((AData)[0]))>* > (AData))

Here is the problem:

bolinux72:gcc {586} ./g++ -v
Reading specs from /usr/local/symbian/lib/gcc-lib/arm-epoc-pe/2.9-psion-98r2/specs
gcc version 2.9-psion-98r2 (Symbian build 546)

bolinux72:gcc {587} ./g++ -pedantic -c ~/stray-unix.c

bolinux72:gcc {588} ./g++ -pedantic -c ~/stray-dos.c
stray-dos.c:1: warning: carriage return in preprocessing directive
stray-dos.c:2: `AType' was not declared in this scope
stray-dos.c:2: `AData' was not declared in this scope
stray-dos.c:2: `AData' was not declared in this scope
stray-dos.c:2: syntax error before `&'

Also:

bolinux72:gcc {589} ./cpp -v
GNU CPP version 2.9-psion-98r2 (Symbian build 546) (ARM/EPOC/PE)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/symbian/lib/gcc-lib/arm-epoc-pe/2.9-psion-98r2/include
 /usr/local/symbian/lib/gcc-lib/arm-epoc-pe/2.9-psion-98r2/../../../../arm-epoc-pe/include
End of search list.

bolinux72:gcc {590} ./cpp -pedantic ~/stray-unix.c
# 1 "/home/afarber/stray-unix.c"





bolinux72:gcc {591} ./cpp -pedantic ~/stray-dos.c
/home/afarber/stray-dos.c:1: warning: carriage return in preprocessing directive 2
# 1 "/home/afarber/stray-dos.c"

        const TFixedArray<AType,(sizeof(AData)/sizeof((AData)[0]))>& \
            AName = *(reinterpret_cast<const TFixedArray<AType, \
                           (sizeof(AData)/sizeof((AData)[0]))>* > (AData))

Now comes my question:

The line "warning: carriage return in preprocessing directive"
I can only find (twice) in the file ./gcc/cccp.c

I've looked into cccp.c and I see there about 12 places where
I probably should change lines like

	if (*bp == '\\' && bp[1] == '\n')
to:
	if (*bp == '\\' && bp[1] == '\r' && bp[2] == '\n')

also I will probably create adapted copies of newline_fix() 
and name_newline_fix().

But my problem is: if I change the lines 
pedwarn ("%s in preprocessing directive".....) in gcc/cccp.c
and issue "gmake clean && gmake", then I can see the changed
output ONLY in the cpp output (s. above). But not in the g++.

Why? Where (from which file) does the g++ warning come from?
Does g++ use some different library?

Thank you
Alex

PS: I've also patched the function skip_white_space()
    in the files ./gcc/cp/lex.c and ./gcc/c-lex.c:

       case '\\':
          c = GETC();
          /* for DOS formatted files skip the CR */
          if (c == '\r')
            c = GETC();
          if (c == '\n')
            lineno++;
          else
            error ("stray '\\' in program");
          c = GETC();
          break;

but that didn't change anything. I also suspect that
1) these files are for C-compilations, not for C++
2) and it is ok to have \r in C/C++ source files, I just 
   need to fix the preprocessing #-statements, correct?



Attachment: gcc-arm-thumb.spec
Description: gcc-arm-thumb.spec


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]