[MacPorts] #41033: cctype functions (e.g. isprint) not defined at link time

MacPorts noreply at macports.org
Mon Oct 28 12:58:54 PDT 2013


#41033: cctype functions (e.g. isprint) not defined at link time
-------------------------+--------------------------------
 Reporter:  schnetter@…  |      Owner:  macports-tickets@…
     Type:  defect       |     Status:  new
 Priority:  Normal       |  Milestone:
Component:  ports        |    Version:  2.2.1
 Keywords:               |       Port:  gcc48
-------------------------+--------------------------------
 I am using Mavericks, and I have C++ code that I want to build with GCC
 4.8 and with the option -std=c++1. This code used std::isprint. The code
 builds fine, but at link time I receive the error message that
 isprint(int) is not defined.

 This code can reproduce the problem:
 {{{
 #include <cctype>
 int main(int argc, char** argv)
 {
   std::isprint('a');
   return 0;
 }
 }}}

 Build it with:
 {{{
 g++ -std=c++11 -o isprint isprint.cc
 }}}
 and the linker will complain:
 {{{
 $ g++ -std=c++11 -o isprint isprint.cc
 Undefined symbols for architecture x86_64:
   "isprint(int)", referenced from:
       _main in cc2AhhUM.o
 ld: symbol(s) not found for architecture x86_64
 }}}

 The problem is that the system file /usr/include/sys/cdefs.h mis-uses a
 GCC extension handling the "inline" keyword. This file needs to be updated
 to not do so when called from C++. This patch does just this:
 {{{
 $ diff -u /usr/include/sys/cdefs.h /opt/local/lib/gcc48/gcc/x86_64-apple-
 darwin13/4.8.1/include-fixed/sys/cdefs.h
 --- /usr/include/sys/cdefs.h    2013-10-23 14:56:58.000000000 -0400
 +++ /opt/local/lib/gcc48/gcc/x86_64-apple-darwin13/4.8.1/include-
 fixed/sys/cdefs.h      2013-10-28 15:28:05.000000000 -0400
 @@ -216,7 +225,7 @@

  #if __STDC_VERSION__ >= 199901L && (!defined(__GNUC__) ||
 defined(__clang__))
  # define __header_inline           inline
 -#elif defined(__GNUC__) && defined(__GNUC_STDC_INLINE__)
 +#elif defined(__GNUC__) && defined(__GNUC_STDC_INLINE__) &&
 !defined(__cplusplus)
  # define __header_inline           extern __inline
 __attribute__((__gnu_inline__))
  #elif defined(__GNUC__)
  # define __header_inline           extern __inline
 }}}

 With this modification, and with the modified file installed into
 /opt/local/lib/gcc48/gcc/x86_64-apple-darwin13/4.8.1/include-
 fixed/sys/cdefs.h, the sample program builds fine.

 I suggest to update gcc-4.8 in this way, i.e. to fix-include
 /usr/include/sys/cdefs.h in this way.

 I assume that gcc-4.7 and maybe other, earlier versions are affected as
 well.

-- 
Ticket URL: <https://trac.macports.org/ticket/41033>
MacPorts <http://www.macports.org/>
Ports system for OS X


More information about the macports-tickets mailing list