Closed GoogleCodeExporter closed 8 years ago
(tcc is a small C compiler)
So your idea is to create on-the-fly compilation for pages, sort of like .py ->
.pyc?
It would make it feel like programming in PHP - just modify the source and
refresh
the page.
I like the idea...
Original comment by csabacs...@gmail.com
on 11 Feb 2010 at 9:49
That would be one example, where the exe is run unless it's source file has
been updated . ( another is that TCC
can already be used as a cgi executor.) Not sure how much overhead would be
involved in determining whether
re-compilation is needed or not.
My thought/wish was implement it such that (one option/the 'normal' operation)
would be to use libtcc to load and
run the .c file in memory -- ala something along the lines of... (the tcc
source ./tests directory has a base
example). I mod'd it slightly here.
I made a quick hack attempt at a proof of concept in mongoose.c. I'll attach
it to the ticket. Someone who knows
mongoose internals better than I should be able to do a better implementation
than I.
/*
* Simple Test program for libtcc
*
* libtcc can be useful to use tcc as a "backend" for a code generator.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "libtcc.h"
int main(int argc, char **argv)
{
TCCState *s;
void *mem;
int size;
int rc = 0;
s = tcc_new();
if (!s) {
fprintf(stderr, "Could not create tcc state\n");
exit(1);
}
/*
tcc_add_include_path(s, "/usr/include");
tcc_add_include_path(s, "/usr/local/lib/tcc/include");
tcc_add_include_path(s, ".");
tcc_add_include_path(s, "/usr/lib/tcc/include");
tcc_add_include_path(s, "/home/jake/src/tcc-0.9.25/tests");
*/
/* if tcclib.h and libtcc1.a are not installed, where can we find them */
// if (argc == 2 && !memcmp(argv[1], "lib_path=",9))
// tcc_set_lib_path(s, argv[1]+9);
/* MUST BE CALLED before any compilation */
tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
rc = tcc_add_file(s, argv[1]);
// fprintf(stderr, "rc = %d\n", rc);
if(rc == -1)
{
fprintf(stderr, "Could not add file\n");
exit(1);
}
rc = tcc_run(s, argc, argv);
// fprintf(stderr, "run rc = %d\n", rc);
if (rc != 0)
{
fprintf(stderr, "Could not run file\n");
exit(1);
}
/* delete the state */
tcc_delete(s);
return 0;
}
jjkjjk
Original comment by jreidtho...@gmail.com
on 12 Feb 2010 at 2:42
Attachments:
Can you be more specific about the use case?
Of course one can use tcc as CGI interpreter and write CGI scripts in C.
But what is the benefit of compiling mongoose source with tcc?
Original comment by valenok
on 20 Sep 2010 at 9:47
Original issue reported on code.google.com by
jreidtho...@gmail.com
on 7 Feb 2010 at 6:06