From nobody@FreeBSD.org  Sat Jan  5 15:41:48 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id BF34037B417
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  5 Jan 2002 15:41:47 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g05Nflp70161;
	Sat, 5 Jan 2002 15:41:47 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200201052341.g05Nflp70161@freefall.freebsd.org>
Date: Sat, 5 Jan 2002 15:41:47 -0800 (PST)
From: Vladimir Kushnir <vkushnir@Alfacom.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: imaxabs(3), imaxdiv(3) does not work with C++ linkage
X-Send-Pr-Version: www-1.0

>Number:         33590
>Category:       misc
>Synopsis:       imaxabs(3), imaxdiv(3) does not work with C++ linkage
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 05 15:50:00 PST 2002
>Closed-Date:    Sun Jan 6 11:05:16 PST 2002
>Last-Modified:  Sun Jan 06 11:07:10 PST 2002
>Originator:     Vladimir Kushnir
>Release:        FreeBSD-CURRENT
>Organization:
ITP
>Environment:
FreeBSD kushnir1.kiev.ua 5.0-CURRENT FreeBSD 5.0-CURRENT #1: Sun Dec 30 10:26:14 EET 2001     root@kushnir1.kiev.ua:/usr/obj/usr/ncvs/src/sys/KUSHNIR  i386    
>Description:
Libc functions imaxabs(3), imaxdiv(3) used in C++ programs lead to "undefined 
reference" errors.   
>How-To-Repeat:
Compile as C++ this code:
/* test.cc */
#include <inttypes.h>

main() {
intmax_t a = 1;
intmax_t b;
imaxdiv_t c;
b = imaxabs(a);
c = imaxdiv(a, b);
}

Output:
~> c++ -o itest test.cc
/tmp/ccplyujk.o: In function `main':
/tmp/ccplyujk.o(.text+0x21): undefined reference to `imaxabs(long long)'
/tmp/ccplyujk.o(.text+0x4e): undefined reference to `imaxdiv(long long, long long)'


>Fix:
      
>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: Vladimir Kushnir <vkushnir@Alfacom.net>, <mike@freebsd.org>
Cc: <freebsd-gnats-submit@freebsd.org>
Subject: Re: misc/33590: imaxabs(3), imaxdiv(3) does not work with C++ linkage
Date: Sun, 6 Jan 2002 23:55:14 +1100 (EST)

 On Sat, 5 Jan 2002, Vladimir Kushnir wrote:
 
 > >Description:
 > Libc functions imaxabs(3), imaxdiv(3) used in C++ programs lead to "undefined
 > reference" errors.
 > >How-To-Repeat:
 > Compile as C++ this code:
 > /* test.cc */
 > #include <inttypes.h>
 >
 > main() {
 > intmax_t a = 1;
 > intmax_t b;
 > imaxdiv_t c;
 > b = imaxabs(a);
 > c = imaxdiv(a, b);
 > }
 >
 > Output:
 > ~> c++ -o itest test.cc
 > /tmp/ccplyujk.o: In function `main':
 > /tmp/ccplyujk.o(.text+0x21): undefined reference to `imaxabs(long long)'
 > /tmp/ccplyujk.o(.text+0x4e): undefined reference to `imaxdiv(long long, long long)'
 >
 >
 > >Fix:
 
 %%%
 Index: inttypes.h
 ===================================================================
 RCS file: /home/ncvs/src/include/inttypes.h,v
 retrieving revision 1.2
 diff -u -2 -r1.2 inttypes.h
 --- inttypes.h	15 Nov 2001 02:05:03 -0000	1.2
 +++ inttypes.h	6 Jan 2002 12:51:47 -0000
 @@ -43,4 +43,5 @@
  } imaxdiv_t;
 
 +__BEGIN_DECLS
  intmax_t	imaxabs(intmax_t) __pure2;
  imaxdiv_t	imaxdiv(intmax_t, intmax_t) __pure2;
 @@ -51,4 +52,5 @@
  intmax_t	wcstoimax(const wchar_t *, wchar_t **, int);
  uintmax_t	wcstoumax(const wchar_t *, wchar_t **, int);
 +__END_DECLS
 
  #endif /* !_INTTYPES_H_ */
 %%%
 
 Bruce
 
State-Changed-From-To: open->feedback 
State-Changed-By: roam 
State-Changed-When: Sun Jan 6 07:32:07 PST 2002 
State-Changed-Why:  
Can you try applying Bruce Evans's patch to the inttypes.h file 
and see if this fixes the problem? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=33590 
State-Changed-From-To: feedback->closed 
State-Changed-By: mike 
State-Changed-When: Sun Jan 6 11:05:16 PST 2002 
State-Changed-Why:  

Fixed in -CURRENT.  Header doesn't yet exist in -STABLE. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=33590 
>Unformatted:
