rishimishra
Programmer
I am trying to compile the following code on multiple platforms( HPUX, SUN, WNT, AIX . I am using xlC_r compiler. I get the errors only on aix and it works on all other platforms.
CODE
====================================================
#include <stdio.h>
#include <iostream.h>
typedef struct intStruct var1;
typedef struct floatStruct var2;
struct intStruct {
int x;
friend var1 initNum1( int a );
friend var1 createInt(var2 in_var);
friend void printInt( var1 a1, char c) { cout << "Integer Value "<< c <<" is "<< a1.x << "\n";}
};
struct floatStruct {
float y;
friend var2 initNum2( float b );
friend var2 createFloat( var1 in_var );
friend void printFloat( var2 b1, char c ) { cout << "float value " << c << " is " << b1.y << "\n";}
};
inline var1 createInt( var2 in_var ) {
return (initNum1( (int)in_var.y ));
}
inline var2 createFloat( var1 in_var ) {
return (initNum2( (float)in_var.x ) );
}
var1 initNum1( int a ) {
var1 num;
num.x = a;
return num;
}
var2 initNum2( float b ) {
var2 num;
num.y = b + 5.6;
return num;
}
main()
{
struct intStruct a;
struct floatStruct b;
struct intStruct c;
struct floatStruct d;
a=initNum1( 22 );
b=initNum2( 25.5 );
c=createInt( b );
d=createFloat( a );
printInt(a, 'a');
printFloat(b, 'b');
printInt(c, 'c');
printFloat(d, 'd');
}
====================================================
The error I got was
=========================================================
"test_code.cpp", line 29.14: 1540-0274 (S) The name lookup for "initNum1" did not find a declaration.
"test_code.cpp", line 36.6: 1540-1298 (I) "var1 initNum1(int)" needs to be declared in the containing scope to be found by name lookup.
"test_code.cpp", line 33.13: 1540-0274 (S) The name lookup for "initNum2" did not find a declaration.
"test_code.cpp", line 42.6: 1540-1298 (I) "var2 initNum2(float)" needs to be declared in the containing scope to be found by name lookup.
==========================================================
Can anybody help me as to why I get this error and what is the solution to this? The code I have pasted is just a sample representation of a very big existing product which until recently was supported only on windows.
thanks in advance
Rishi
CODE
====================================================
#include <stdio.h>
#include <iostream.h>
typedef struct intStruct var1;
typedef struct floatStruct var2;
struct intStruct {
int x;
friend var1 initNum1( int a );
friend var1 createInt(var2 in_var);
friend void printInt( var1 a1, char c) { cout << "Integer Value "<< c <<" is "<< a1.x << "\n";}
};
struct floatStruct {
float y;
friend var2 initNum2( float b );
friend var2 createFloat( var1 in_var );
friend void printFloat( var2 b1, char c ) { cout << "float value " << c << " is " << b1.y << "\n";}
};
inline var1 createInt( var2 in_var ) {
return (initNum1( (int)in_var.y ));
}
inline var2 createFloat( var1 in_var ) {
return (initNum2( (float)in_var.x ) );
}
var1 initNum1( int a ) {
var1 num;
num.x = a;
return num;
}
var2 initNum2( float b ) {
var2 num;
num.y = b + 5.6;
return num;
}
main()
{
struct intStruct a;
struct floatStruct b;
struct intStruct c;
struct floatStruct d;
a=initNum1( 22 );
b=initNum2( 25.5 );
c=createInt( b );
d=createFloat( a );
printInt(a, 'a');
printFloat(b, 'b');
printInt(c, 'c');
printFloat(d, 'd');
}
====================================================
The error I got was
=========================================================
"test_code.cpp", line 29.14: 1540-0274 (S) The name lookup for "initNum1" did not find a declaration.
"test_code.cpp", line 36.6: 1540-1298 (I) "var1 initNum1(int)" needs to be declared in the containing scope to be found by name lookup.
"test_code.cpp", line 33.13: 1540-0274 (S) The name lookup for "initNum2" did not find a declaration.
"test_code.cpp", line 42.6: 1540-1298 (I) "var2 initNum2(float)" needs to be declared in the containing scope to be found by name lookup.
==========================================================
Can anybody help me as to why I get this error and what is the solution to this? The code I have pasted is just a sample representation of a very big existing product which until recently was supported only on windows.
thanks in advance
Rishi