Skip to main content

alphaWorks  >  Forums  >  decNumber++  >  developerWorks

Compilation errors with GNU c++ 4.1 on Linux    Point your RSS reader here for a feed of the latest messages in this thread


     

 
 

My developerWorks
 Welcome, Guest
Sign in or register
Permlink Replies: 2 - Pages: 1 - Last Post: May 29, 2009 4:13 AM Last Post By: Arin_Ray Threads: [ Previous | Next ]

Posts: 3
Registered: Jan 23, 2007 10:50:03 AM
Compilation errors with GNU c++ 4.1 on Linux
Posted: Jan 23, 2007 10:56:12 AM
Click to report abuse...   Click to reply to this thread Reply
I'm trying to compile decNumber++ using g++ on Linux. Unfortunately, I'm hitting compile errors due to the use of the forward-declared decimal32/64/128 classes in the extended_num_put/get templates:

% g++ --version
g++ (GCC) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  1. From the "impl" directory:
% g++ -O2 -c -I.. -I/pub/apps/linux-i686/include *.cpp
../impl/decIO.h: In member function '_Iter std::decimal::extended_num_put<_CharT, _Iter>::put(_Iter, std::ios_base&, _CharT, std::decimal::decimal32) const':
../impl/decIO.h:138: error: '_V' has incomplete type
../impl/decCommon.h:54: error: forward declaration of 'struct std::decimal::decimal32'
../impl/decIO.h: In member function '_Iter std::decimal::extended_num_put<_CharT, _Iter>::put(_Iter, std::ios_base&, _CharT, std::decimal::decimal64) const':
../impl/decIO.h:141: error: '_V' has incomplete type
../impl/decCommon.h:55: error: forward declaration of 'struct std::decimal::decimal64'
../impl/decIO.h: In member function '_Iter std::decimal::extended_num_put<_CharT, _Iter>::put(_Iter, std::ios_base&, _CharT, std::decimal::decimal128) const':
../impl/decIO.h:144: error: '_V' has incomplete type
../impl/decCommon.h:56: error: forward declaration of 'struct std::decimal::decimal128'
../impl/decIO.h: In member function 'virtual _Iter std::decimal::extended_num_put<_CharT, _Iter>::do_put(_Iter, std::ios_base&, _CharT, std::decimal::decimal32) const':
../impl/decIO.h:171: error: '_V' has incomplete type
../impl/decCommon.h:54: error: forward declaration of 'struct std::decimal::decimal32'
../impl/decIO.h: In member function 'virtual _Iter std::decimal::extended_num_put<_CharT, _Iter>::do_put(_Iter, std::ios_base&, _CharT, std::decimal::decimal64) const':
../impl/decIO.h:177: error: '_V' has incomplete type
../impl/decCommon.h:55: error: forward declaration of 'struct std::decimal::decimal64'
../impl/decIO.h: In member function 'virtual _Iter std::decimal::extended_num_put<_CharT, _Iter>::do_put(_Iter, std::ios_base&, _CharT, std::decimal::decimal128) const':
../impl/decIO.h:183: error: '_V' has incomplete type
../impl/decCommon.h:56: error: forward declaration of 'struct std::decimal::decimal128'
../impl/decIO.h: At global scope:
../impl/decIO.h:565: warning: large integer implicitly truncated to unsigned type
../impl/decIO.h:565: warning: large integer implicitly truncated to unsigned type
../impl/decIO.h:565: warning: large integer implicitly truncated to unsigned type
../impl/decIO.h:565: warning: large integer implicitly truncated to unsigned type
../impl/decIO.h:565: warning: large integer implicitly truncated to unsigned type
../impl/decIO.h:565: warning: large integer implicitly truncated to unsigned type
../impl/decIO.h: In member function '_Iter std::decimal::extended_num_put<_CharT, _Iter>::put(_Iter, std::ios_base&, _CharT, std::decimal::decimal32) const':
../impl/decIO.h:138: error: '_V' has incomplete type
../impl/decCommon.h:54: error: forward declaration of 'struct std::decimal::decimal32'
../impl/decIO.h: In member function '_Iter std::decimal::extended_num_put<_CharT, _Iter>::put(_Iter, std::ios_base&, _CharT, std::decimal::decimal64) const':
../impl/decIO.h:141: error: '_V' has incomplete type
../impl/decCommon.h:55: error: forward declaration of 'struct std::decimal::decimal64'
../impl/decIO.h: In member function '_Iter std::decimal::extended_num_put<_CharT, _Iter>::put(_Iter, std::ios_base&, _CharT, std::decimal::decimal128) const':
../impl/decIO.h:144: error: '_V' has incomplete type
../impl/decCommon.h:56: error: forward declaration of 'struct std::decimal::decimal128'
../impl/decIO.h: In member function 'virtual _Iter std::decimal::extended_num_put<_CharT, _Iter>::do_put(_Iter, std::ios_base&, _CharT, std::decimal::decimal32) const':
../impl/decIO.h:171: error: '_V' has incomplete type
../impl/decCommon.h:54: error: forward declaration of 'struct std::decimal::decimal32'
../impl/decIO.h: In member function 'virtual _Iter std::decimal::extended_num_put<_CharT, _Iter>::do_put(_Iter, std::ios_base&, _CharT, std::decimal::decimal64) const':
../impl/decIO.h:177: error: '_V' has incomplete type
../impl/decCommon.h:55: error: forward declaration of 'struct std::decimal::decimal64'
../impl/decIO.h: In member function 'virtual _Iter std::decimal::extended_num_put<_CharT, _Iter>::do_put(_Iter, std::ios_base&, _CharT, std::decimal::decimal128) const':
../impl/decIO.h:183: error: '_V' has incomplete type
../impl/decCommon.h:56: error: forward declaration of 'struct std::decimal::decimal128'
../impl/decIO.h: At global scope:
../impl/decIO.h:565: warning: large integer implicitly truncated to unsigned type
../impl/decIO.h:565: warning: large integer implicitly truncated to unsigned type
../impl/decIO.h:565: warning: large integer implicitly truncated to unsigned type
../impl/decIO.h:565: warning: large integer implicitly truncated to unsigned type
../impl/decIO.h:565: warning: large integer implicitly truncated to unsigned type
../impl/decIO.h:565: warning: large integer implicitly truncated to unsigned type

The code compiles cleanly on g++ 3.3 and 3.4, but I'd prefer to use the 4.1.x series as that is what I am using for the rest of my applications.

Posts: 3
Registered: Jan 23, 2007 10:50:03 AM
Re: Compilation errors with GNU c++ 4.1 on Linux
Posted: Jan 30, 2007 09:36:56 AM   in response to: in response to: 's post
Click to report abuse...   Click to reply to this thread Reply
Wow, fix was pretty simple. Just use const references in the method signatures. See attached diff.

code
diff -ur decNumber++-1.0.orig/impl/decIO.h decNumber++-1.0/impl/decIO.h
      • decNumber++-1.0.orig/impl/decIO.h 2006-07-09 18:35:22.000000000 -0400
+ decNumber++-1.0/impl/decIO.h 2007-01-30 09:33:04.097571000 -0500
@@ -135,13 +135,13 @@
_Base(_NumPut) {}

_Iter put(_Iter _S, std::ios_base & _F, char_type _Fill,
  • decimal32 _V) const
+ const decimal32& _V) const
{ return do_put(_S, _F, _Fill, _V); }
_Iter put(_Iter _S, std::ios_base & _F, char_type _Fill,
  • decimal64 _V) const
+ const decimal64& _V) const
{ return do_put(_S, _F, _Fill, _V); }
_Iter put(_Iter _S, std::ios_base & _F, char_type _Fill,
  • decimal128 _V) const
+ const decimal128& _V) const
{ return do_put(_S, _F, _Fill, _V); }

_Iter put(_Iter _S, std::ios_base & _F, char_type _Fill,
@@ -168,19 +168,19 @@
protected:

virtual _Iter do_put(_Iter _S, std::ios_base & _F, char_type _Fill,
  • decimal32 _V) const
+ const decimal32& _V) const
{
_DecNumber _D(_V);
return _D._DoPut(_S, _F, _Fill);
}
virtual _Iter do_put(_Iter _S, std::ios_base & _F, char_type _Fill,
  • decimal64 _V) const
+ const decimal64& _V) const
{
_DecNumber _D(_V);
return _D._DoPut(_S, _F, _Fill);
}
virtual _Iter do_put(_Iter _S, std::ios_base & _F, char_type _Fill,
  • decimal128 _V) const
+ const decimal128& _V) const
{
_DecNumber _D(_V);
return _D._DoPut(_S, _F, _Fill);
[/code]
Arin_Ray

Posts: 1
Registered: May 29, 2009 04:07:49 AM
Re: Compilation errors with GNU c++ 4.1 on Linux
Posted: May 29, 2009 04:13:05 AM   in response to: in response to: 's post
Click to report abuse...   Click to reply to this thread Reply
Hi,

Just faced the same problem and this fix works for the compilation errors "_V has incomplete type".
Any clues as to why this happens on gcc 4.1.2 and why the fix works?

Also how important is to address the warnings "../hdr/impl/decIO.h:565: warning: large integer implicitly truncated to unsigned type" ?
I made these go away by changing "#define DECDPUN" from 3 to 8 in decNumber.h in the decNumber C library.

Thanks in advance

Arindam

Point your RSS reader here for a feed of the latest messages in all forums