fluid-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] Building with -ansi


From: Pedro Lopez-Cabanillas
Subject: Re: [fluid-dev] Building with -ansi
Date: Sun, 20 Mar 2011 12:52:52 +0100
User-agent: KMail/1.13.5 (Linux/2.6.34.7-0.7-desktop; KDE/4.4.4; i686; ; )

On Sunday 20 March 2011, Matt Giuca wrote:
> Hi,
> 
> My apologies for causing bug
> #97<https://sourceforge.net/apps/trac/fluidsynth/ticket/97>.
> Judging by plcl's fix:
> http://fluidsynth.svn.sourceforge.net/viewvc/fluidsynth/trunk/fluidsynth/src/midi/fluid_midi.c?r1=408&r2=411
> 
> I declared a variable not at the top of a function and didn't cast a void*
> to a char*, which apparently MSVC doesn't like. I (like I assume many
> developers) don't have MSVC to test on. Both of these flaws appear to be
> because my code was not ANSI compliant (David and I had a bit of a chat
> about this in the MIDI buffer thread).
> 
> I wonder if it would be possible to change the CMake list file so the gcc
> version builds with -ansi. I haven't tried it to see what happens (as I
> don't know CMake), but I would assume if MSVC is strict about
> ANSI-compliance, then the code should already be compliant, and therefore
> turning this flag on won't break anything. If we build with -ansi, I
> believe, GCC will error out on these things so it won't be so easy to break
> the MSVC build. Just a thought.

You can use this command line at configuration time:
$ cmake [...] -DCMAKE_C_FLAGS=-ansi

It doesn't build, though. FluidSynth source code is not ANSI C compliant. MSVC 
is C90 with a few additional features of C99, but not including the 
"intermingled declarations and code" syntax. See:  
http://en.wikipedia.org/wiki/C99

Instead of the "-ansi" flag, you may prefer "-pedantic". It reports as warnings 
all the code not conforming with C90, for instance in this case: "warning: ISO 
C90 forbids mixed declarations and code". A much more focused GCC  flag to trap 
this particular mistake is "-Wdeclaration-after-statement", which may be 
included in the CMakeLists.txt if nobody objects.

Regards,
Pedro



reply via email to

[Prev in Thread] Current Thread [Next in Thread]