gtk-peer compile fixes for gcc-2.95

Mark Wielaard mark@klomp.org
Fri Apr 9 14:03:00 GMT 2004


Hi,

On Wed, 2004-04-07 at 22:25, Mark Wielaard wrote:
> On Mon, 2004-04-05 at 19:43, Tom Tromey wrote:
> > >>>>> "Mark" == Mark Wielaard <mark@klomp.org> writes:
> > 
> > Mark> The attached patch does that and enables -Wall for GNU Classpath.
> > 
> > Nice.  I skimmed it and it generally looks fine to me.
> > 
> > Mark> It fixes all issues found when compiling with -std=c89. Lots in the gtk
> > Mark> peers I am afraid. So please yell and scream if this is to intrusive. It
> > Mark> would be good if the gtk-peer stuff in libgcj was also compiled with
> > Mark> this flag.
> > 
> > I think it is a requirement, not just nice to have.  Otherwise we're
> > going to end up reintroducing code that isn't C89.
> > 
> > Here's an untested patch for the GUI branch.
> > 
> > from  Tom Tromey  <tromey@redhat.com>
> > 
> > 	* Makefile.am (WARNINGS): Added -std=c89.
> 
> Thanks for that.
> 
> Here is the gtk+ peer part of my patch.
> I'll commit this to classpath now.
> Could someone commit it to libgcj mainline and/or gui?
> (I only have a 3.4 branch checkout on my development machine at the
> moment.)
> 
> I want to test the other part of my patch first more carefully before
> committing to classpath and enabling -std=c89

OK I tested some more and here is what I came up with:
-ansi -std=c89 -pedantic -Wall -Wno-long-long -D_POSIX_SOURCE
-D_BSD_SOURCE
This gives us ISO C90 pedantic ansi, but with longlong (jlong) support
and modern POSIX and BSD C library functions/prototypes (we actually
need fsync and ftruncate for example which aren't in ISO C 90 so the
glibc headers wouldn't define it with the above two defines).

I have even gone through the complete source to make sure we can clean
it up so much to enable even -Werror. But when discussion some of the
changes on irc people pointed out that some of the "fixes" actually only
made the warnings go away and not the real problem gcc was warning about
(especially with the "dereferencing type-punned pointer will break
strict-aliasing rules" warnings).

So here is just the minimal safe patch (mostly just wat Tom already
reviewed) to enable the above without -Werror. With all the language
lawyering going on I didn't dare to make changes that might infuriate
some C purist :) I'll study the warnings that are now generated by
default some more and suggest fixes, but others are more then welcome to
do the same!

If someone could enable the above flags also for libgcj and/or add at
least the native/gtk-peer parts to libgcj (mainline/gui-branch) that
would be nice.

2004-04-09  Mark Wielaard  <mark@klomp.org>

      * configure.ac: Set AM_CFLAGS to ISO C90 pedantic ansi, but with
      longlong (jlong) support and modern POSIX and BSD C library
      funtions/prototypes.
      * native/fdlibm/Makefile.am: Cancel out project wide AM_CFLAGS.
      * native/fdlibm/mprec.h: Remove C++ comments.
      * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c: Turn C++
      comments into C comments.
      * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c:
      Likewise.
      * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c:
      Likewise.
      * native/jni/java-io/FileDescriptor.c: Likewise.
      * native/jni/java-io/java_io_File.c: Likewise.
      * native/jni/java-io/javaio.c: Remove unused fprintf calls.
      * native/jni/java-net/javanet.c: Turn C++ comments into C comments.
      * native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c:
      Likewise.
      * native/target/generic/target_generic_file.h: Likewise.
      * native/target/generic/target_generic_network.h: Likewise.

Cheers,

Mark


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ansi-pedantic.patch
Type: text/x-patch
Size: 16451 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040409/066fc15f/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040409/066fc15f/attachment.sig>


More information about the Java-patches mailing list