Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: mex compiling error
Date: Mon, 21 Sep 2009 13:46:19 +0000 (UTC)
Organization: Universit&#228;t Bern
Lines: 36
Message-ID: <h9803b$fkp$1@fred.mathworks.com>
References: <h97rq1$3nc$1@fred.mathworks.com> <d102bc34-8206-4f28-b692-281de004e561@f33g2000vbm.googlegroups.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 1253540779 16025 172.30.248.37 (21 Sep 2009 13:46:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 21 Sep 2009 13:46:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1490572
Xref: news.mathworks.com comp.soft-sys.matlab:571787


Rune Allnor <allnor@tele.ntnu.no> wrote in message <d102bc34-8206-4f28-b692-281de004e561@f33g2000vbm.googlegroups.com>...
> 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

Sorry Rune, but I guess there is no time for a C programming cource at the moment... So how can I initialize the array at run time?