Thread Subject: Errors during mex compilation on certain systems

Subject: Errors during mex compilation on certain systems

From: Kasper Marstal

Date: 23 Jan, 2010 17:11:03

Message: 1 of 5

Hello,

I have a mex c-file that compiles beautifully on my mac and latop, but my Windows 7 x64 system using Microsoft Visual C++ 2008 SP1 throw lots of errors..



>> mex simap.c
simap.c
simap.c(29) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
simap.c(30) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
simap.c(35) : error C2143: syntax error : missing ';' before 'type'
simap.c(36) : error C2143: syntax error : missing ';' before 'type'
simap.c(52) : error C2065: 'simaps' : undeclared identifier
simap.c(52) : error C2109: subscript requires array or pointer type
simap.c(52) : error C2065: 'simaps' : undeclared identifier
simap.c(52) : error C2109: subscript requires array or pointer type
simap.c(58) : error C2065: 'simaps' : undeclared identifier
simap.c(58) : error C2109: subscript requires array or pointer type
simap.c(58) : error C2065: 'simaps' : undeclared identifier
simap.c(58) : error C2109: subscript requires array or pointer type
simap.c(58) : error C2168: 'exp' : too few actual parameters for intrinsic function
simap.c(61) : error C2065: 'simaps' : undeclared identifier
simap.c(61) : error C2109: subscript requires array or pointer type
simap.c(72) : error C2065: 'simaps' : undeclared identifier
simap.c(72) : error C2109: subscript requires array or pointer type
simap.c(72) : error C2065: 'simaps' : undeclared identifier
simap.c(72) : error C2109: subscript requires array or pointer type
simap.c(77) : error C2065: 'g' : undeclared identifier
simap.c(77) : error C2109: subscript requires array or pointer type


'simaps' and 'g' _is_ declared and I dont get any of the exp-, missing ';' or pow-related errors on the other systems.

Any way to work around this?

Subject: Errors during mex compilation on certain systems

From: James Tursa

Date: 23 Jan, 2010 21:42:06

Message: 2 of 5

"Kasper Marstal" <lifesucksandthenyoudie@gmail.com> wrote in message <hjfaj7$gk6$1@fred.mathworks.com>...
> Hello,
>
> I have a mex c-file that compiles beautifully on my mac and latop, but my Windows 7 x64 system using Microsoft Visual C++ 2008 SP1 throw lots of errors..
>
> >> mex simap.c
(snip)
> simap.c(35) : error C2143: syntax error : missing ';' before 'type'
> simap.c(36) : error C2143: syntax error : missing ';' before 'type'
> simap.c(52) : error C2065: 'simaps' : undeclared identifier
(snip)
>
> 'simaps' and 'g' _is_ declared and I dont get any of the exp-, missing ';' or pow-related errors on the other systems.
>
> Any way to work around this?

Can't possibly advise reasonably without seeing your code. My guess is the declarations for simaps and g are on lines 35 and 36. Since these lines have syntax errors and didn't compile, you get the downstream errors. Start with fixing lines 35 and 36.

James Tursa

Subject: Errors during mex compilation on certain systems

From: Rune Allnor

Date: 23 Jan, 2010 22:11:25

Message: 3 of 5

On 23 Jan, 18:11, "Kasper Marstal" <lifesucksandthenyou...@gmail.com>
wrote:
> Hello,
>
> I have a mex c-file that compiles beautifully on my mac and latop, but my Windows 7 x64 system using Microsoft Visual C++ 2008 SP1 throw lots of errors..

You need to take particular care when writing C and C++ programs
that are supposed to be portable. Both languages have a core
that is standardized, and that at leat in principle should
compile on every platform.

However, there are many ways to depart from the standard,
either by leaving out standardized features (or rather,
compiler vendors have not yet implemented recently
standardized features), or by adding platform- or compiler-
specific libraries or features.

There are also variations on how strict any particular
compiler will be with respect to syntax and warnings, etc.

Once you are aware of these kinds of things, there are a
few guidelines you can use to minimize such problems:

1) Strictly stick to standardized C or C++ code. Don't
   use compiler-, OS- or platform-specific libraries,
   as these will get you into trouble when you attempt
   to port.
2) Learn your compiler. Most compilers have switches and
   directives that either disable non-standard features
   and / or forces the compiler to accept only standardized
   code.
3) Compile the same code on several systems and compilers.
   What one compiler accepts, another will reject. Like what
   probably is the case in your code.

In addition, use type declarations like size_t, ptrdiff_t
and so on, instead of int, unsigned int, long int etc.
These are the kinds of things that are almost certain to
cause trouble when porting between platforms.

Rune

Subject: Errors during mex compilation on certain systems

From: Lai Chiong Ching

Date: 11 May, 2011 07:19:05

Message: 4 of 5

Have anyone solved this issue??? The error occur because of variable declaratin is done after some statements/expression. If ALL the variable is declared first before any other statement, there won't be any error.

Does anyone knows how to work-around this as it somehow impose some limitation??

cheers

"Kasper Marstal" wrote in message <hjfaj7$gk6$1@fred.mathworks.com>...
> Hello,
>
> I have a mex c-file that compiles beautifully on my mac and latop, but my Windows 7 x64 system using Microsoft Visual C++ 2008 SP1 throw lots of errors..
>
>
>
> >> mex simap.c
> simap.c
> simap.c(29) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
> simap.c(30) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
> simap.c(35) : error C2143: syntax error : missing ';' before 'type'
> simap.c(36) : error C2143: syntax error : missing ';' before 'type'
> simap.c(52) : error C2065: 'simaps' : undeclared identifier
> simap.c(52) : error C2109: subscript requires array or pointer type
> simap.c(52) : error C2065: 'simaps' : undeclared identifier
> simap.c(52) : error C2109: subscript requires array or pointer type
> simap.c(58) : error C2065: 'simaps' : undeclared identifier
> simap.c(58) : error C2109: subscript requires array or pointer type
> simap.c(58) : error C2065: 'simaps' : undeclared identifier
> simap.c(58) : error C2109: subscript requires array or pointer type
> simap.c(58) : error C2168: 'exp' : too few actual parameters for intrinsic function
> simap.c(61) : error C2065: 'simaps' : undeclared identifier
> simap.c(61) : error C2109: subscript requires array or pointer type
> simap.c(72) : error C2065: 'simaps' : undeclared identifier
> simap.c(72) : error C2109: subscript requires array or pointer type
> simap.c(72) : error C2065: 'simaps' : undeclared identifier
> simap.c(72) : error C2109: subscript requires array or pointer type
> simap.c(77) : error C2065: 'g' : undeclared identifier
> simap.c(77) : error C2109: subscript requires array or pointer type
>
>
> 'simaps' and 'g' _is_ declared and I dont get any of the exp-, missing ';' or pow-related errors on the other systems.
>
> Any way to work around this?

Subject: Errors during mex compilation on certain systems

From: Rune Allnor

Date: 11 May, 2011 07:54:53

Message: 5 of 5

On May 11, 9:19 am, "Lai Chiong Ching" <chiong....@gmail.com> wrote:
> Have anyone solved this issue??? The error occur because of variable declaratin is done after some statements/expression. If ALL the variable is declared first before any other statement, there won't be any error.
>
> Does anyone knows how to work-around this as it somehow impose some limitation??

I 'solved' the issue the day after the question was asked:

http://groups.google.com/group/comp.soft-sys.matlab/msg/2201f5155cede04c

The gist is simple: Learn how to use your tools.

Rune

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com