Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: mex compiling error
Date: Mon, 21 Sep 2009 14:54:05 +0000 (UTC)
Organization: Universit&#228;t Bern
Lines: 48
Message-ID: <h9842d$67r$1@fred.mathworks.com>
References: <h97rq1$3nc$1@fred.mathworks.com> <d102bc34-8206-4f28-b692-281de004e561@f33g2000vbm.googlegroups.com> <da8e5411-2998-41a4-afb4-97952f12037e@z34g2000vbl.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 1253544845 6395 172.30.248.37 (21 Sep 2009 14:54:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 21 Sep 2009 14:54:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1490572
Xref: news.mathworks.com comp.soft-sys.matlab:571806


Rune Allnor <allnor@tele.ntnu.no> wrote in message <da8e5411-2998-41a4-afb4-97952f12037e@z34g2000vbl.googlegroups.com>...
> On 21 Sep, 15:46, "Stephan " <schm...@pyl.unibe.ch> wrote:
> > Rune Allnor <all...@tele.ntnu.no> wrote in message <d102bc34-8206-4f28-b692-281de004e...@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...
> 
> Then stay away from MEX. If you are unwilling to do what it
> takes to learn how to program C, you will only get pain and
> misery from the attempt. Not to mention that you will waste
> ten times a smuch time as if you coded whatever you are up
> to, directly in matlab.
> 
> Rune

Rune, calm down a bit... breathe in - breathe out!!! Better now? I did C-Courses during my education, but it's been a while. If you are a C-pro and my posts are annoying to you, just ignore them! You really don't have to answer them, but I think those user-communities are exactly to ask questions like that. So if any polite people want to answer my questions, feel free...