|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
mex should treat C files as C++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 _______________________________________________ Bug-octave mailing list Bug-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: mex should treat C files as C++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. |
|
|
Re: mex should treat C files as C++tor, 08 01 2009 kl. 05:54 -0800, skrev dbateman:
> 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. Okay, so I tried compiling the offending code in Matlab, and it breaks there as well. I've been struck by this problem with many peoples mex code so I thought Matlab did something weird like always compiling with a C++ compiler, but it turns out they don't. I guess Visual Studio allows this behaviour which just makes people sloppy. Anyway, sorry about the noise... Søren _______________________________________________ Bug-octave mailing list Bug-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: mex should treat C files as C++Am Donnerstag, den 08.01.2009, 16:00 +0100 schrieb Søren Hauberg:
> tor, 08 01 2009 kl. 05:54 -0800, skrev dbateman: > > 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. > > Okay, so I tried compiling the offending code in Matlab, and it breaks > there as well. I've been struck by this problem with many peoples mex > code so I thought Matlab did something weird like always compiling with > a C++ compiler, but it turns out they don't. I guess Visual Studio > allows this behaviour which just makes people sloppy. You can include stdlib.h. Thomas _______________________________________________ Bug-octave mailing list Bug-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: mex should treat C files as C++On Thu, Jan 08, 2009 at 04:25:55PM +0100, Thomas Weber wrote:
> Am Donnerstag, den 08.01.2009, 16:00 +0100 schrieb Søren Hauberg: > > tor, 08 01 2009 kl. 05:54 -0800, skrev dbateman: > > > 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. > > > > Okay, so I tried compiling the offending code in Matlab, and it breaks > > there as well. I've been struck by this problem with many peoples mex > > code so I thought Matlab did something weird like always compiling with > > a C++ compiler, but it turns out they don't. I guess Visual Studio > > allows this behaviour which just makes people sloppy. > > You can include stdlib.h. Urgs, that should be stdbool.h. Thomas _______________________________________________ Bug-octave mailing list Bug-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave |
| Free embeddable forum powered by Nabble | Forum Help |