Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!f33g2000vbm.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: mex compiling error
Date: Mon, 21 Sep 2009 05:42:26 -0700 (PDT)
Organization: http://groups.google.com
Lines: 37
Message-ID: <d102bc34-8206-4f28-b692-281de004e561@f33g2000vbm.googlegroups.com>
References: <h97rq1$3nc$1@fred.mathworks.com>
NNTP-Posting-Host: 77.16.181.125
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1253536946 21912 127.0.0.1 (21 Sep 2009 12:42:26 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 21 Sep 2009 12:42:26 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: f33g2000vbm.googlegroups.com; posting-host=77.16.181.125; 
	posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; 
	Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; 
	.NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:571780


On 21 Sep, 14:33, "Stephan " <schm...@pyl.unibe.ch> wrote:
> Hi there
>
> I have a problem compiling my Mex-Files. this is the code:
>
> ...
> // Variable declarations
> int const nrOfFrames = (int)mxGetScalar(prhs[0]);   // Input variable, nr. of frames to load    
> BYTE *pData[nrOfFrames]; // Pointer for image data
> ...
>
> If I'm compiling this, I'm getting following error:
>
> >> mex cameraTest.cpp
>
> cameraTest.cpp
> cameraTest.cpp(40) : error C2057: expected constant expression
> cameraTest.cpp(40) : error C2466: cannot allocate an array of constant size 0
> cameraTest.cpp(40) : error C2133: 'pData' : unknown size
>
>   C:\PROGRA~1\MATLAB\R2009A\BIN\MEX.PL: Error: Compile of 'cameraTest.cpp' failed.
>
> Why do I get this error? I thought nrOfFrames is a constant value cause it's defined as a constant...

The constant is not known at compile time, which is why
you get the error. You need to use some sort of memory
allocation function at run-time to initialize the array.

Since you make these types of mistakes, you might want to
take a class or cource on C or C++ programming before
venturing too far into in the MEX world.

Rune