Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Errors during mex compilation on certain systems

376 views
Skip to first unread message

Kasper Marstal

unread,
Jan 23, 2010, 12:11:03 PM1/23/10
to
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?

James Tursa

unread,
Jan 23, 2010, 4:42:06 PM1/23/10
to
"Kasper Marstal" <lifesucksan...@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

Rune Allnor

unread,
Jan 23, 2010, 5:11:25 PM1/23/10
to
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

Lai Chiong Ching

unread,
May 11, 2011, 3:19:05 AM5/11/11
to
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>...

Rune Allnor

unread,
May 11, 2011, 3:54:53 AM5/11/11
to
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

Abeera Tariq

unread,
May 28, 2015, 9:12:01 AM5/28/15
to
i am getting same errors how to resolve them?
0 new messages