Re: compiling and gcc2.7.0

From: Clifford Beshers <beshers_at_cs.columbia.edu>
Date: Wed, 22 May 1996 13:19:51 -0400 (EDT)

   Resent-Date: Wed, 22 May 1996 13:07:34 -0400 (EDT)
   Date: Wed, 22 May 1996 12:06:53 -0400
   From: Jonathan Berry <berryj_at_dimacs.rutgers.edu>
   Resent-From: stk_at_kaolin.unice.fr
   X-Mailing-List: <stk_at_kaolin.unice.fr> archive/latest/1158
   X-Loop: stk_at_kaolin.unice.fr
   Precedence: list
   Resent-Sender: stk-request_at_kaolin.unice.fr
   Content-Type: text
   Content-Length: 1066

   Just a note on portability -

   stk.h includes string.h and memory.h. When STk is compiled using C++,
   the entire stk.h file is enclosed in an extern "C" environment. For
   some reason which I haven't taken the time to determine, including
   string.h and memory.h in such an environment bombs the compilation
   with g++2.7.0. I have have no problem with 2.7.2 or 2.6.3.
   Moving the includes of string.h and memory.h outside of the extern "C"
   solves the problem in 2.7.0.
           Jon

   This was the error:
   /usr/local/gnu/lib/g++-include/std/cstring.h: In function `char * strchr(char *, int)':
   In file included from /usr/local/gnu/lib/g++-include/cstring:5,
                    from /usr/local/gnu/lib/g++-include/string.h:5,
                    from /usr/local/packages/STk/build/Src/stk.h:39,
                    from STkTemplateFiles.cc:2:
   /usr/local/gnu/lib/g++-include/std/cstring.h:34: declaration of C function `char * strchr(char *, int)' conflicts with
   /usr/local/gnu/lib/g++-include/std/cstring.h:31: previous declaration `char * strchr(const char *, int)' here
   ....
   ...
   ...


I had to do this with 2.7.2 on hpux. Those header files really should
not be inside the extern "C". I suggested this some time ago, and
provided patches. Any C++ environment should provide versions that
work correctly included normally.

The reason you get errors is that the C++ versions often have the
const's added for extra information for the compiler. They are not in
the C version because many C compilers don't understand const. C++
views f(const char *c) and f(char *c) as two different functions.

Cliff

-- 
Clifford Beshers                     Computer Graphics and User Interfaces Lab
beshers_at_cs.columbia.edu                         Department of Computer Science
http://www.cs.columbia.edu/~beshers                        Columbia University
Received on Wed May 22 1996 - 19:21:59 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST