1751979 Members
4640 Online
108784 Solutions
New Discussion юеВ

Re: aCC error

 
SOLVED
Go to solution
vikram n.r
New Member

aCC error

Hi,

I am using aCC to compile a C++ code.
aCC version - aCC: HP ANSI C++ B3910B A.03.70

in HP UX 11i

I have a class which contains a function as below.

class ActivitiesFilters {
BaseError addUserFilters(string& lotnumber, string& wafernumb
er, string& chip);
};

Where BaseError is the class depending on which error conditions are checked.

Now, I am calling the function from the Cpp file. As below
BaseError statusR;
statusR = addUserFilters(string("*"), string("*"), string("*"));


The compiler says


Error 438: "src/activities_filters.cpp", line 608 # The initializer for a
non-constant reference must be an lvalue. Try changing
'basic_string,allocator> &' to 'const
basic_string,allocator> &' at
["./inc/activities_filters.h", line 563].
statusR = addUserFilters(string("*"), string("*"), string("*"));


Can anybody suggest me any solution for this error because the same code is working fine in windows .net and vc++ compilers.


thanks in advance
Vikram
4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: aCC error

>Can anybody suggest me any solution for this error because the same code is working fine in windows .net and vc++ compilers.

I can't see how, this code is illegal.

As the proto says, this takes a reference to a string.
BaseError addUserFilters(string&, string&, string&);

But the temp result of a string constructor isn't a lvalue. As the error message says, you must change these to const&. Or you must create a temp for your string("*").

Dennis Handly
Acclaimed Contributor
Solution

Re: aCC error

>But the temp result of a string constructor isn't a reference.

(I should have said isn't a lvalue.)

aCC6 gives: warning #2461-D, unless +strict is used to make it an error.
aCC3 gives: Error (future) 438 unless +p is used to make it an error.
vikram n.r
New Member

Re: aCC error

Hi Dennis,

Thats right there is +p flag in the Makefile under CXXFLAGS. I removed that flag and compiled the code is compiling fine with warnings.


thank you very much
Vikram
Dennis Handly
Acclaimed Contributor

Re: aCC error

If you are happy with your answers, you should read the following on how to assign points:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33