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: Bernhard Fischer
Subject: Re: [Tinycc-devel] what are tcc's limitations?
Date: Wed, 22 Nov 2006 19:04:09 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

On Mon, Oct 16, 2006 at 07:33:15PM -0600, Joel Buckley wrote:
>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?

hm?

Works transparently for me..
address@hidden:~/src/tinycc.stdin$ echo -e "#include <stdio.h>\nint 
main(void){puts(\"Hello, world..\");return 15;}" | ./tcc -run - ; echo $?
Hello, world..
15
address@hidden:~/src/tinycc.stdin$ 

>
>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?




reply via email to

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