This is the mail archive of the gcc-bugs@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]

[Bug preprocessor/41492] New: Please ignore #! on the first line of a file


I have a file that I would like to be able to either execute with a C
interpreter, or compile with GCC.
As you know, Unix uses "#!/path/to/interpreter" to invoke scripts.  Consider
the following program:

#!/usr/bin/c-interpreter
int main() { printf("Hello World\n"); }

It would be nice if this could be compiled by GCC, simple by ignoring the first
line of the file.  The current error message is:
hello.c:1:2: error: invalid preprocessing directive #!

One easy fix would be to define the preprocessing directive #! as a legal
directive, which swallows the rest of the line.  This would work with C, C++,
and ObjC, but not the other languages.  Another possibility that would work
universally is to make #! as the first two characters of an input file a
"special case" comment specifier in all front-ends.  It doesn't need to be
recognized anywhere except as the first two bytes of a file.

Please consider this small but useful feature as it will help me with writing
portable code that can be interpreted as well as compiled.


-- 
           Summary: Please ignore #! on the first line of a file
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: preprocessor
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drwowe at yahoo dot com
 GCC build triplet: All
  GCC host triplet: All
GCC target triplet: All


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


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