mex should treat C files as C++

dbateman dbateman at free.fr
Thu Jan 8 07:54:24 CST 2009




Søren Hauberg wrote:
> 
> Hi All,
>   Once in a while I have to use mex files that people distribute. Or
> rather, I have to compile the source code they distribute using the
> 'mex' command. A couple of times I have been struck be a small issue:
> Some people seem to use non-C keywords (e.g. 'true' and 'false') in
> their code, but they save the source code in a file that ends with
> '.c' (like 'my_function.c'). When I run the 'mex' command I get errors
> like these:
> 
>   kernel_function.c: In function ‘mexFunction’:
>   kernel_function.c:37: fejl: ‘true’ undeclared (first use in this
> function)
>   kernel_function.c:37: fejl: (Each undeclared identifier is reported
> only once
>   kernel_function.c:37: fejl: for each function it appears in.)
>   kernel_function.c:44: fejl: ‘false’ undeclared (first use in this
> function)
> 
> The problem goes away if I rename the files to something that ends with
> '.cc'. I guess this means 'mkoctfile' (which is called by 'mex') uses
> 'gcc' and not 'g++'. Could we change this, such that 'g++' is called
> instead of 'gcc'?
> 
> Søren
> 
> 

true and false are not valid C keywords. Adding

#define true 1
#define false 0

somewhere, but keep compiling the code with gcc would be a cleaner solution.

D.
-- 
View this message in context: http://www.nabble.com/mex-should-treat-C-files-as-C%2B%2B-tp21347863p21352160.html
Sent from the Octave - Bugs mailing list archive at Nabble.com.




More information about the Bug-octave mailing list