Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Dec 2002 23:43:48 +0200 (EET)
From:      "Vladimir I. Chukharev" <chu@gpi.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   standards/46504: Warnings in headers
Message-ID:  <200212232143.gBNLhmel011523@h33.erkki.ton.tut.fi>

next in thread | raw e-mail | index | archive | help

>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 <cstdlib>
#include <string>
#include <iostream>
#include <fstream>
#include <vector>

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200212232143.gBNLhmel011523>