From: Kasper Marstal on
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?
From: James Tursa on
"Kasper Marstal" <lifesucksandthenyoudie(a)gmail.com> wrote in message <hjfaj7$gk6$1(a)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
From: Rune Allnor on
On 23 Jan, 18:11, "Kasper Marstal" <lifesucksandthenyou...(a)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
 | 
Pages: 1
Prev: Simple Problem
Next: Hough transform