Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: mex compiling error
Date: Fri, 2 Oct 2009 06:31:39 +0000 (UTC)
Organization: Boeing
Lines: 21
Message-ID: <ha46ob$fg3$1@fred.mathworks.com>
References: <h97rq1$3nc$1@fred.mathworks.com> <d102bc34-8206-4f28-b692-281de004e561@f33g2000vbm.googlegroups.com> <h9803b$fkp$1@fred.mathworks.com> <h984l4$ft2$1@fred.mathworks.com> <h9iot7$n89$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1254465099 15875 172.30.248.37 (2 Oct 2009 06:31:39 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 2 Oct 2009 06:31:39 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:574406


"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <h9iot7$n89$1@fred.mathworks.com>...
> Dear James, dear Stephan!
> 
> > James Tursa wrote:
> > P.S. Variable Length Arrays, where the array size is determined at run-time, *are* part of the current C Standard, but they are *not* part of the C++ standard. Having said that, many popular C compilers such as Microsoft Visual C (at least up to 8 ... I haven't tried 9 yet) and the lcc that ships with MATLAB, do not support Variable Length Arrays yet.
> 
> Apart from Rune's personal opinion about valid C-code, the current LCC 3.8.?  does support variable length arrays of the C99 standard:
>   http://www.cs.virginia.edu/~lcc-win32/
> Matlab R2009a (most likely 2009b also) does not recognize this LCC version automatically in "mex -setup", but it is easy to modify the mexopts.bat of the shipped LCC 2.4.1 (adjust the paths, disable the RSP-file support!). 
> 
> For an explanation about variable length arrays of the C99 standard see also:
>   http://en.wikipedia.org/wiki/Variable-length_array
>   http://www.ddj.com/cpp/184401444
> 
> Kind regards, Jan

Thanks, Jan. I don't have this version of lcc installed, but maybe when I get some time I will download it and try to hook it up with MATLAB.

FYI, there was a thread some time ago on comp.lang.c (3/5/2008 with the title "Variable length arrays") that discussed VLA use with the lcc compiler. Seems that lcc does *not* free up the dynamic memory allocated to VLA variables when they go out of scope. So a simple loop with a VLA variable that only has scope in the loop continuously eats up memory and eventually crashes the program (allocates a new VLA variable on each iteration of the loop without freeing the previous VLA variable). The lcc author apparently doesn't consider this a bug, but others do. I am not a C Standard expert, so I don't know about the conformance of this, but IMO it is a serious flaw in the compiler that needs fixing even if it isn't strictly a conformance "bug".

James Tursa