tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] what are tcc's limitations?


From: Joel Buckley
Subject: Re: [Tinycc-devel] what are tcc's limitations?
Date: Mon, 16 Oct 2006 19:33:15 -0600
User-agent: Thunderbird 1.5 (X11/20060113)

Bernhard,

I like it.

Is there a way to "echo ...|tcc" and have the compiled code
executed directly, e.g. without creating the "./no" file?

Cheers,
leoJ
Thinking backwards from the solution ;)


Bernhard Fischer wrote:
On Mon, Oct 16, 2006 at 11:40:41AM +0200, Bernhard Fischer wrote:

Consider this invalid code:
$ cat no.c
int main(void) {}
$ tcc -o no no.c && ./no ; echo $? ; ./no ; echo $?
228
212

and a half now, so the -run mode is a viable scripting language.

For scripting mode it would be handy to be able to compile from stdin,
btw. Something like this, but perhaps without using /dev/stdin but 0
would seem to be appropriate.

$ echo -e "#include <stdio.h>\nint main(void) {printf(\"%s\", \"Hello,
world.\\\n\");return 0;}" | tcc -o no -  && ./no
Hello, world.

diff -u ../tinycc.stdin.oorig/tcc.c ./tcc.c
--- ../tinycc.stdin.oorig/tcc.c 2005-09-04 00:51:34.000000000 +0200
+++ ./tcc.c     2006-10-16 12:50:07.000000000 +0200
@@ -10427,7 +10427,10 @@
                 break;
         }
         r = argv[optind++];
-        if (r[0] != '-') {
+        if (r[0] == '-' && r[1] == '\0') {
+            /* add stdin */
+            dynarray_add((void ***)&files, &nb_files, "/dev/stdin");
+        } else if (r[0] != '-') {
             /* add a new file */
             dynarray_add((void ***)&files, &nb_files, r);
             if (!multiple_files) {

Sounds useful?


_______________________________________________
Tinycc-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/tinycc-devel






reply via email to

[Prev in Thread] Current Thread [Next in Thread]