[Top][All Lists]

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

Re: [Tinycc-devel] argument length limt for scripts?

From: David Mertens
Subject: Re: [Tinycc-devel] argument length limt for scripts?
Date: Thu, 13 Jun 2013 12:09:00 -0500

On Thu, Jun 13, 2013 at 11:56 AM, Stevie G. Messervey <address@hidden> wrote:

From: David Mertens <address@hidden>
To: address@hidden
Sent: Thursday, June 13, 2013 12:29 PM

Subject: Re: [Tinycc-devel] argument length limt for scripts?

Don't you need something more like this?

#if 0
exec /path/to/tcc ...your args here...
/* C code goes here */

That is brilliant and works perfectly! I don't know how, but it does!
Thank you so much!!!

P.S. I modified libtcc to accept .cgi as a valid source file extension.
For anyone else interested:
libtcc.c line 1132
change:  if (!ext[0] || !PATHCMP(ext, "c")) {
to:  if (!ext[0] || !PATHCMP(ext, "c") || !PATHCMP(ext, "cgi")) {

Tinycc-devel mailing list

In case your curious, this is how it works: We need a file that can be interpreted by both bash and TCC. Bash interprets all lines that begin with a octothorp (#) as a comment, and bash stops interpreting the file as soon as it hits the exec statement. It doesn't even try to interpret the rest. TCC ignores the first line when it is a shebang line (TCC is unique here; other compilers don't ignore this, I believe) and then the preprocessor removes the lines between the #if 0 and the #endif, which contains the bash code. TCC then compiiles the rest of the file as C code.

These are the sorts of tricks that let you write one file that can be executed by more than one language interpreter or compiler.


 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan

reply via email to

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