Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!z34g2000vbl.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 07:05:42 -0700 (PDT)
Organization: http://groups.google.com
Lines: 45
Message-ID: <da8e5411-2998-41a4-afb4-97952f12037e@z34g2000vbl.googlegroups.com>
References: <h97rq1$3nc$1@fred.mathworks.com> <d102bc34-8206-4f28-b692-281de004e561@f33g2000vbm.googlegroups.com> 
	<h9803b$fkp$1@fred.mathworks.com>
NNTP-Posting-Host: 77.16.56.29
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: posting.google.com 1253541942 7090 127.0.0.1 (21 Sep 2009 14:05:42 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 21 Sep 2009 14:05:42 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: z34g2000vbl.googlegroups.com; posting-host=77.16.56.29; 
	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:571795


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