Operating System - HP-UX
1753491 Members
4592 Online
108794 Solutions
New Discussion юеВ

Whats wrong with this code

 
SOLVED
Go to solution
Anwarul Kabir
Advisor

Whats wrong with this code

if ( layout != 0 &&
!_stat_values.insert(
pair(
static_cast((layout * 100) + (file_in.get_data()[2] - '0') ),
1L ) ).second )
{
_stat_values[ ( layout * 100 ) + ( file_in.get_data()[2] - '0' ) ]++;
}


Error that I am getting in aCC 6 is
"file_line_proc.cpp", line 768: error #2020: identifier "_stat_values" is
undefined
!_stat_values.insert(
^


BTW this code is working aCC 3...
4 REPLIES 4
Anwarul Kabir
Advisor

Re: Whats wrong with this code

Sorry discard my first post i found the problem. the declartion was commented out in the header file. I don't know how it was compiled or some thing...

Anyway now i got another error
"/opt/aCC/include_std/memory", line 278: error #2403: invalid redeclaration of
member function "std::allocator<_TypeT>::address(_TypeT &) const
[with _TypeT=const long]" (declared at line 274)
const_pointer address (const_reference __x) const {
^
detected during:
instantiation of class
"std::allocator<_TypeT> [with _TypeT=const long]" at
line 88 of "/opt/aCC/include_std/rw/tree"
instantiation of class "__rw::__rw_rb_tree_node<_Alloc, _Val,
_Key, _KeyOf> [with
_Alloc=std::allocator<:pair>>,
_Val=std::pair, _Key=const long,
_KeyOf=__rw::__select1st<:pair>,
const long>]" at line 282 of
"/opt/aCC/include_std/rw/tree"
instantiation of class "__rw::__rb_tree<_Key, _Val, _KeyOf, _Comp,
_Alloc> [with _Key=const long, _Val=std::pair long, long>, _KeyOf=__rw::__select1st<:pair>
long, long>, const long>, _Comp=std::less,
_Alloc=std::allocator<:pair>>]" at
line 102 of "/opt/aCC/include_std/map"
instantiation of class "std::map<_Key, _TypeT, _Compare,
_Allocator> [with _Key=const long, _TypeT=long,
_Compare=std::less,
_Allocator=std::allocator<:pair>>]"
at line 69 of
"../../../lib/process_data/inc/file_line_proc.h"

I know the shared files r working as they r used by other application I think...
Anwarul Kabir
Advisor

Re: Whats wrong with this code

so this is where it must be doing something wrong


instantiation of class "std::map<_Key, _TypeT, _Compare,
_Allocator> [with _Key=const long, _TypeT=long,
_Compare=std::less,
_Allocator=std::allocator<:pair>>]"
at line 69 of
"../../../lib/process_data/inc/file_line_proc.h"
Dennis Handly
Acclaimed Contributor
Solution

Re: Whats wrong with this code

>BTW this code is working aCC3

This old compiler doesn't meet the Standard. If you are porting to aCC6, you should read the "aC++ standard conformance and compatibility changes":
http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=2708d7c682f02110d7c682f02110275d6e10RCRD

Your problem is: ISO-39. aCC6 detects instantiation conflicts earlier (2403)
http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=2708d7c682f02110d7c682f02110275d6e10RCRD#_iso-39._acc6_detects_instantiation_

You have several problems:
_stat_values.insert(pair(static_cast(layout),1L))

You should never directly use pair or make_pair when you want to use maps. You should never use "const T" in a cast or function type, since top level CV qualifiers are ignored.

What you should do is:
typedef std::map mapLL;
mapLL _stat_values;
_stat_values.insert(mapLL::value_type(layout,1L))

Your real problem is you can't use "const long" as a key in a map:
error #2403: invalid redeclaration of member function "std::allocator::address() const [with _TypeT=const long]"

>so this is where it must be doing something wrong
instantiation of class "std::map<_Key, _TypeT> [with _Key=const long, _TypeT=long,
at line 69 of file_line_proc.h

Right, remove that illegal "const".
Anwarul Kabir
Advisor

Re: Whats wrong with this code

yeap it was that constant...