xlC compilation error when dealing with operator overloading


 
Thread Tools Search this Thread
Operating Systems AIX xlC compilation error when dealing with operator overloading
# 1  
Old 04-09-2008
xlC compilation error when dealing with operator overloading

Hi,

I have a piece of C++ code that can be compiled using g++, but reports an error when compiled with xlC:

xlC -DHAVE_CONFIG_H -I../SRC -I../include -DNoChange -DSPRNG_MPI -q64 -DLONG64=long -I/usr/lpp/ppe.poe/include -DLONG64=long -c -o libsprng_a-bignum.o bignum.cpp
"bignum.cpp", line 1280.8: 1540-0040 (S) The text "&" is unexpected. "ostream" may be undeclared or ambiguous.



The code segment is as below:

ostream& operator << (ostream& os, const BigNum& bn)
{
unsigned long int * ptr;
unsigned long int i = 1;

if (!bn.v)
return os;

ptr = bn.v + bn.Size() - 1;

os.setf(ios::uppercase);
os << hex << *ptr--;

while (i < bn.size) {
i++;

if (NUMBITS == 32)
os << setw(8) << setfill('0') << hex << *ptr--;
else
os << setw(16) << setfill('0') << hex << *ptr--;
}

os << endl;
// ptr = 0;

return os;
}
# 2  
Old 04-09-2008
Solved

The problem has been solved

it would have been nice to tell us how you have solved it in exchange for our willingness to solve it for you if you would not have been able to do it yourself.

Last edited by bakunin; 04-10-2008 at 05:48 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C++ operator overloading error

hi, I defined my own String class and overloaded the output operator with friend ostream& operator<<(ostream& os, const myString& str); //overloads the << operator so it can be used to output values of type myString which works fine. Until I try to execute the following statement: // +... (6 Replies)
Discussion started by: milhan
6 Replies

2. Programming

c++ assignment operator overloading

Hello everyone! Suppose that I have something like this A a; a.mem=new int; A b = a; where class A { public: int * mem; A() : mem(NULL) { } ~A() { if (mem!=NULL) delete mem; (1 Reply)
Discussion started by: bashuser2
1 Replies

3. UNIX for Advanced & Expert Users

XLC compiler: enterprise edition VS XLC for AIX

Who can explain in a few words the difference between XLC for AIX and XLC enterprise Edition for AIX (0 Replies)
Discussion started by: fvaltat1
0 Replies

4. Programming

Delete operator overloading with multiple arguments.

Hi, I have an requirement to overload the delete operator in C++, but it should also accept the sizeof() the object that is to be deleted. Actually I am trying to built a custom memory allocator and deallocator like a pool, which makes me to overload the delete operator. Small example of the... (1 Reply)
Discussion started by: kapilkumawat
1 Replies

5. Programming

C++ Optr Overloading

Hi All, In C++ one operator can be overloaded, but it can't be overloaded by it's own derieved class Please let me know operator. Thanks, Naga:cool: (1 Reply)
Discussion started by: Nagapandi
1 Replies

6. Programming

Compilation error : Please help

state_field state_abvr = { "AL","ALABAMA", "AK","ALASKA", "AZ","ARIZONA", "AR","ARKANSAS", "CA","CALIFORNIA", "CO","COLORADO", "CT","CONNECTICUT", "DE","DELAWARE", "DC","DISTRICT-OF-COLUMBIA", "FL","FLORIDA", "GA","GEORGIA", "HI","HAWAII", "ID","IDAHO", "IL","ILLINOIS",... (1 Reply)
Discussion started by: jagan_kalluri
1 Replies

7. Linux

c++ compilation error

Hello every one, here i am attempting to compile a c++ module using gcc.it is throwing a error . error: ==== > make -S dummyCHARGP /usr/local/bin/gcc -g -DDEBUG -DMAT -I. -I/swtemp/usbs/cc/unix-ce/root/subsys/lib/Linux/ -I/opt/dce/include -I/opt/dce/include/dce ... (12 Replies)
Discussion started by: mannam srinivas
12 Replies

8. Programming

Compilation error

I am compiling a software xchm on solaris 10. First i run './configure' There is no error. But when i start compiling using 'gmake' following error shown /usr/local/include/wx-2.6/wx/x11/brush.h: In copy constructor `wxBrush::wxBrush(const wxBrush&)':... (3 Replies)
Discussion started by: mansoorulhaq
3 Replies

9. Programming

compilation error

Hi, While trying compile a C++ file in UNIX with gcc whose make rule involves the usage of /usr/ccs/bin/as, I get the following error: /usr/ccs/bin/as: No such file or directory /usr/ccs/bin/as: error: write error on output file "<filename>.o" *** Error code 1 clearmake: Error: Build... (2 Replies)
Discussion started by: smanu
2 Replies

10. Programming

Regarding compilation error.

Hi All, I facing the following compilation error; when I implementing the following logic. ostrstream ostr; ostr << (( scAxsm.getRecord( i ).getField( 2 ).getShort())%12)!=0?(( scAxsm.getRecord( i ).getField( 2 ).getShort())/12+1) : (( scAxsm.getRecord( i ).getField( 2 ).getShort())/12) <<... (1 Reply)
Discussion started by: sweta
1 Replies
Login or Register to Ask a Question