From owner-freebsd-standards Mon Dec 23 13:50:12 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4984F37B401 for ; Mon, 23 Dec 2002 13:50:07 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6944B43EF7 for ; Mon, 23 Dec 2002 13:50:06 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id gBNLo6NS040218 for ; Mon, 23 Dec 2002 13:50:06 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id gBNLo61c040217; Mon, 23 Dec 2002 13:50:06 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DF17137B401 for ; Mon, 23 Dec 2002 13:44:57 -0800 (PST) Received: from h33.erkki.ton.tut.fi (h33.erkki.ton.tut.fi [193.166.84.86]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0E62443EDE for ; Mon, 23 Dec 2002 13:44:57 -0800 (PST) (envelope-from chu@h33.erkki.ton.tut.fi) Received: from h33.erkki.ton.tut.fi (chu@localhost [127.0.0.1]) by h33.erkki.ton.tut.fi (8.12.3/8.12.3) with ESMTP id gBNLhnCF011524 for ; Mon, 23 Dec 2002 23:43:49 +0200 (EET) (envelope-from chu@h33.erkki.ton.tut.fi) Received: (from chu@localhost) by h33.erkki.ton.tut.fi (8.12.3/8.12.3/Submit) id gBNLhmel011523; Mon, 23 Dec 2002 23:43:48 +0200 (EET) Message-Id: <200212232143.gBNLhmel011523@h33.erkki.ton.tut.fi> Date: Mon, 23 Dec 2002 23:43:48 +0200 (EET) From: "Vladimir I. Chukharev" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/46504: Warnings in headers Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 46504 >Category: standards >Synopsis: Warnings in headers >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Dec 23 13:50:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Vladimir I. Chukharev >Release: FreeBSD 4.7-STABLE i386 >Organization: >Environment: System: FreeBSD svak.h33.erkki.ton.tut.fi 4.7-STABLE FreeBSD 4.7-STABLE #0: Wed Nov 27 21:35:04 EET 2002 root@svak.h33.erkki.ton.tut.fi:/usr/obj/usr/src/sys/SVAK i386 >Description: I am used to have as strict checks in gcc/g++ as possible. Sometimes it helps to find some silly mistakes. In FreeBSD headers g++ makes lots of warnings. So I started to correct the most annoing places. Is it interesting to anybody? >How-To-Repeat: Save these Makefile and tt.cc in current directory and run make. OPTIMIZE may need adjusting. The two commented out switches give much more warnings (those are not addressed in the patch below). --- Makefile begins here --- HDRS = SRCS = tt.cc DATA = OBJS = tt.o PROGRAM = tt DEST = . CC = g++ CFLAGS = $(OPTIMIZE) $(INCLUDE) $(WARNINGS) OPTIMIZE = \ -pipe \ -O3 \ -mcpu=pentium \ -march=pentium INCLUDE = -I/usr/X11R6/include WARNINGS = \ -ansi \ -pedantic \ -W \ -Wall \ -Wbad-function-cast \ -Wcast-align \ -Wcast-qual \ -Wconversion \ -Wid-clash-12 \ -Winline \ -Wlong-long \ -Wmissing-declarations \ -Wmissing-noreturn \ -Wmissing-prototypes \ -Wnested-externs \ -Woverloaded-virtual \ -Wpointer-arith \ -Wredundant-decls \ -Wreorder \ -Wshadow \ -Wsign-promo \ -Wstrict-prototypes \ -Wtraditional \ -Wundef \ -Wwrite-strings \ # # The following give too many errors in headers. # -Waggregate-return \ # -Wold-style-cast \ LD = $(CC) LDFLAGS = INSTALL = install INSTFLAGS = MF = Makefile all: $(PROGRAM) clean:; -rm -f $(OBJS) *.core core cleanall:; -rm -f $(OBJS) *.core core $(PROGRAM) install: $(PROGRAM) $(INSTALL) $(INSTFLAGS) $(PROGRAM) $(DEST) # tt.o: $(MF) tt.cc $(CC) $(CFLAGS) -c tt.cc tt: $(MF) tt.o $(LD) $(LDFLAGS) tt.o -o tt --- Makefile ends here --- --- tt.cc begins here --- #include #include #include #include #include using namespace std; int main() { cout << "Hello world!" << endl; return EXIT_SUCCESS; } --- tt.cc ends here --- >Fix: Well, this is not a fix, because it corrects installed files instead of sources in /usr/src/. If there is any interest, I can try to do it more correct next time. --- headers.patch begins here --- --- /usr/include/g++/cstdlib Sun Dec 22 22:17:44 2002 +++ /usr/include/g++/cstdlib.orig Sun Dec 22 22:16:29 2002 @@ -11,7 +11,7 @@ extern "C++" { -#if defined(_G_HAS_LABS) && _G_HAS_LABS +#if _G_HAS_LABS inline long abs(long x) { return labs (x); } #else inline long abs(long x) { return x >= 0 ? x : -x; } --- /usr/include/g++/iostream.h Sun Dec 22 19:37:52 2002 +++ /usr/include/g++/iostream.h.orig Sun Dec 22 19:33:56 2002 @@ -250,7 +250,7 @@ extern _IO_ostream_withassign cout, cerr; extern _IO_ostream_withassign clog -#if defined(_G_CLOG_CONFLICT) +#if _G_CLOG_CONFLICT __asm__ ("__IO_clog") #endif ; --- /usr/include/g++/streambuf.h Sun Dec 22 19:40:28 2002 +++ /usr/include/g++/streambuf.h.orig Sun Dec 22 19:38:58 2002 @@ -55,7 +55,7 @@ #endif #ifndef _IO_wchar_t -#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 +#if _G_IO_IO_FILE_VERSION == 0x20001 #define _IO_wchar_t _G_wchar_t #else #define _IO_wchar_t short @@ -413,7 +413,7 @@ virtual streampos sys_seek(streamoff, _seek_dir); virtual int sys_close(); virtual int sys_stat(void*); // Actually, a (struct stat*) -#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 +#if _G_IO_IO_FILE_VERSION == 0x20001 virtual int showmanyc(); virtual void imbue(void *); #endif --- /usr/include/stdlib.h Sun Dec 22 19:53:04 2002 +++ /usr/include/stdlib.h.orig Sun Dec 22 19:49:25 2002 @@ -106,11 +106,11 @@ void srand __P((unsigned)); double strtod __P((const char *, char **)); long strtol __P((const char *, char **, int)); -__extension__ long long +long long strtoll __P((const char *, char **, int)); unsigned long strtoul __P((const char *, char **, int)); -__extension__ unsigned long long +unsigned long long strtoull __P((const char *, char **, int)); int system __P((const char *)); --- /usr/include/sys/cdefs.h Sun Dec 22 19:48:23 2002 +++ /usr/include/sys/cdefs.h.orig Sun Dec 22 19:43:08 2002 @@ -270,13 +270,13 @@ */ /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1 +#if _POSIX_C_SOURCE == 1 #undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */ #define _POSIX_C_SOURCE 199009 #endif /* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */ -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2 +#if _POSIX_C_SOURCE == 2 #undef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 199209 #endif --- headers.patch ends here --- Best regards, V.Chukharev >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message