tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] static const not recognized as const value?


From: Aharon Robbins
Subject: Re: [Tinycc-devel] static const not recognized as const value?
Date: Mon, 27 Dec 2010 19:03:38 +0200
User-agent: Heirloom mailx 12.4 7/29/08

Hi.

The answer is that this feature is not in C.  It is in C++, which
may be why you think it ought to work.  :-)

I too am amazed by tcc's speed. When I use it to compile gawk, though,
three of my tests, all related to wide characters, fail. I haven't
time to investigate why, though.

HTH,

Arnold

> Date: Mon, 27 Dec 2010 14:50:06 +0100
> From: Stephan Beal <address@hidden>
> To: address@hidden
> Subject: [Tinycc-devel] static const not recognized as const value?
>
> Hi, TCCers!
>
> (This is my first post to the list.)
>
> Every now and then i write code like the following:
>
> static const size_t sz = 1024 * 2;
> char buffer[sz];
> ...
>
> tcc complains that sz is not a constant expression, which "just doesn't seem
> right" to me. It does of course accept:
>
> enum { sz = 1024 * 2 };
> char buffer[sz];
>
> but i'm quite pedantic about type safety, and hate having to cast my enum
> values to size_t (or whatever) during later calls which use the "sz" value.
>
> Is there a particular reason which tcc  (0.9.25) doesn't recognize static
> consts as const values? i understand that tcc doesn't support C99 vararrays,
> but a static const isn't quite the same as using, e.g., a value passed to
> the function as the array size. (Or maybe they are the same, from tcc's
> point of view?) This behaviour has been, in recent months, the only place i
> have to retroactively change code to make it work in tcc.
>
> :-?
>
> PS: tcc's speed amazes me every time i use it. See the second gray box at:
> http://fossil.wanderinghorse.net/repos/whio/index.cgi/wiki/AmalgamationBuild
>
> -- 
> ----- stephan beal
> http://wanderinghorse.net/home/stephan/



reply via email to

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