Reputation: 2890
I'm new to Matlab and was trying to build a C file. The code gets compiled fine with gcc (4.8.4 in 64-bit Ubuntu). But when I try to build with mex
, it shows following error:
error: exponent has no digits
I'm not sure what I'm doing wrong. The error is in this file. Complete error log is here.
When I compile the code using gcc, there are no errors. I do not provide any special arguments to gcc. To my knowledge, mex
is using gcc
so I do not understand why mex
is failing to build the code.
I've little knowledge of C programming and any help is highly appreciated!
Edit:
To clarify more, I've got the source in two files:
File 1 has the C code with a main
function, and uses functions from this
file (which mex
can not build).
File 2 has the C code of the S-Function
which call's File 1's main
function. File 2 has an include
statement to include File 1
.
When I said I can build using gcc
, I just built File 1
with this command: gcc file1.c -o file1
. I think not building File 2
with gcc
has no impact here in my question, as only File 1 uses those functions from the file which mex
can not build.
I used this command from Matlab mex file2.c
to build and got the error.
Upvotes: 1
Views: 147
Reputation: 30579
For C code, you probably need to enable GNU extensions for C99 (-std=gnu99
). As described in my previous post on enabling C99, to pass this to mex
:
mex -v -largeArrayDims CFLAGS="\$CFLAGS -std=gnu99" mexSouce.c
The reason the default does not work is because mex
likes to choose the ANSI standard, which is often not the newest.
Upvotes: 1