Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!r36g2000vbn.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 08:24:37 -0700 (PDT)
Organization: http://groups.google.com
Lines: 61
Message-ID: <bb8c0f11-0b2c-4316-ad05-f7a3bfa809a8@r36g2000vbn.googlegroups.com>
References: <h97rq1$3nc$1@fred.mathworks.com> <d102bc34-8206-4f28-b692-281de004e561@f33g2000vbm.googlegroups.com> 
	<da8e5411-2998-41a4-afb4-97952f12037e@z34g2000vbl.googlegroups.com> 
	<h9842d$67r$1@fred.mathworks.com>
NNTP-Posting-Host: 77.16.120.171
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: posting.google.com 1253546677 23969 127.0.0.1 (21 Sep 2009 15:24:37 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 21 Sep 2009 15:24:37 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: r36g2000vbn.googlegroups.com; posting-host=77.16.120.171; 
	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:571818


On 21 Sep, 16:54, "Stephan " <schm...@pyl.unibe.ch> wrote:
> Rune Allnor <all...@tele.ntnu.no> wrote in message <da8e5411-2998-41a4-afb4-97952f120...@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 ever had a C course, you would know about memory allocation.

> 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...

If you don't have the time to look up your own old class notes,
pain and misery will follow. This is not the place to get free
C education or to have C programs debugged.

If you are in such a hurry to get a result, code matlab.

Rune