From: Jan Simon on
Dear readers!

Unfortuantely I cannot test it by my own, because I stuck on a Windows-machine. I thought this command would instruct the GCC compiler to accept the C99 comment style using "//":
mex -O CFLAGS="\$CFLAGS -std=C99" Shuffle.c
It is not a problem of the parsing - same effects for:
me(' -O', 'CFLAGS="\$CFLAGS -std=C99"', 'Shuffle.c')
(double quotes - char(34) - before \ and after 99)

On a 64 bit Linux machine using 2010a and GCC 4.4.1 this yields to the message:
cc1: error: unrecognized command line option "-std=C99"

In addition the MEX command suggests:
Warning: You are using gcc version "4.4.1-4ubuntu9)". The version
currently supported with MEX is "4.2.3".

While I've never seen problems to use the C99 (Or C++) comment style on Windows machines, it seems like the GCC is more sensitive. Can this be solved by another flag for the compiler? Lower case "c99" ?!
Is the C99 style still too fresh ?!

Thanks, Jan
From: Oliver Woodford on
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hoj2mc$8bn$1(a)fred.mathworks.com>...
> Dear readers!
>
> Unfortuantely I cannot test it by my own, because I stuck on a Windows-machine. I thought this command would instruct the GCC compiler to accept the C99 comment style using "//":
> mex -O CFLAGS="\$CFLAGS -std=C99" Shuffle.c
> It is not a problem of the parsing - same effects for:
> me(' -O', 'CFLAGS="\$CFLAGS -std=C99"', 'Shuffle.c')
> (double quotes - char(34) - before \ and after 99)
>
> On a 64 bit Linux machine using 2010a and GCC 4.4.1 this yields to the message:
> cc1: error: unrecognized command line option "-std=C99"
>
> In addition the MEX command suggests:
> Warning: You are using gcc version "4.4.1-4ubuntu9)". The version
> currently supported with MEX is "4.2.3".
>
> While I've never seen problems to use the C99 (Or C++) comment style on Windows machines, it seems like the GCC is more sensitive. Can this be solved by another flag for the compiler? Lower case "c99" ?!
> Is the C99 style still too fresh ?!
>
> Thanks, Jan

Jan, I struggled with this problem for a while. In the end I could find no command line flag that would stop the error, so I removed the -ansi flag from my mexopts.sh file.

If anyone does come up with a way to over-ride this flag from the matlab command line, and allow C++ style comments, then I'd also love to hear about it.

Oliver
From: James Tursa on
"Oliver Woodford" <o.j.woodford.98(a)cantab.net> wrote in message <hojmpg$btv$1(a)fred.mathworks.com>...
> "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hoj2mc$8bn$1(a)fred.mathworks.com>...
> > Dear readers!
> >
> > Unfortuantely I cannot test it by my own, because I stuck on a Windows-machine. I thought this command would instruct the GCC compiler to accept the C99 comment style using "//":
> > mex -O CFLAGS="\$CFLAGS -std=C99" Shuffle.c
> > It is not a problem of the parsing - same effects for:
> > me(' -O', 'CFLAGS="\$CFLAGS -std=C99"', 'Shuffle.c')
> > (double quotes - char(34) - before \ and after 99)
> >
> > On a 64 bit Linux machine using 2010a and GCC 4.4.1 this yields to the message:
> > cc1: error: unrecognized command line option "-std=C99"
> >
> > In addition the MEX command suggests:
> > Warning: You are using gcc version "4.4.1-4ubuntu9)". The version
> > currently supported with MEX is "4.2.3".
> >
> > While I've never seen problems to use the C99 (Or C++) comment style on Windows machines, it seems like the GCC is more sensitive. Can this be solved by another flag for the compiler? Lower case "c99" ?!
> > Is the C99 style still too fresh ?!
> >
> > Thanks, Jan
>
> Jan, I struggled with this problem for a while. In the end I could find no command line flag that would stop the error, so I removed the -ansi flag from my mexopts.sh file.
>
> If anyone does come up with a way to over-ride this flag from the matlab command line, and allow C++ style comments, then I'd also love to hear about it.
>
> Oliver

I second that motion.

James Tursa
From: Jan Simon on
Dear Oliver!

> > mex -O CFLAGS="\$CFLAGS -std=c99" Shuffle.c

> Jan, I struggled with this problem for a while. In the end I could find no command line flag that would stop the error, so I removed the -ansi flag from my mexopts.sh file.

As far as I understood "-ansi" is documented to be "-std=c89", so this *must* conflict with "-std=c99". This means, that the "-ansi" should be removed from the mexopts if the user does not want to restrict the C-code to a 20 year old standard.

Google found this, but I cannot try it (no Liniux currently):
mex -O CFLAGS="\$CFLAGS -Wp,-lang-c-c++-comments" Shuffle.c

Kind regards, Jan
From: Oliver Woodford on
"Jan Simon" wrote:
> As far as I understood "-ansi" is documented to be "-std=c89", so this *must* conflict with "-std=c99". This means, that the "-ansi" should be removed from the mexopts if the user does not want to restrict the C-code to a 20 year old standard.

I agree there is a conflict. The question is how is this conflict resolved. What I wondered is if there was any option that would over-ride (i.e. take precedence over) the default behaviour of -ansi compilation. I'm looking for a solution that doesn't require people I give my code to to edit their mexopts file.

> Google found this, but I cannot try it (no Liniux currently):
> mex -O CFLAGS="\$CFLAGS -Wp,-lang-c-c++-comments" Shuffle.c

I think I've tried that, but I'll try it again.

Regards,
Oliver