Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with function name lookup in a source file 1

Status
Not open for further replies.

rishimishra

Programmer
Joined
Jan 15, 2004
Messages
2
Location
US
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 << &quot;Integer Value &quot;<< c <<&quot; is &quot;<< a1.x << &quot;\n&quot;;}
};

struct floatStruct {
float y;

friend var2 initNum2( float b );

friend var2 createFloat( var1 in_var );

friend void printFloat( var2 b1, char c ) { cout << &quot;float value &quot; << c << &quot; is &quot; << b1.y << &quot;\n&quot;;}
};

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
=========================================================
&quot;test_code.cpp&quot;, line 29.14: 1540-0274 (S) The name lookup for &quot;initNum1&quot; did not find a declaration.
&quot;test_code.cpp&quot;, line 36.6: 1540-1298 (I) &quot;var1 initNum1(int)&quot; needs to be declared in the containing scope to be found by name lookup.
&quot;test_code.cpp&quot;, line 33.13: 1540-0274 (S) The name lookup for &quot;initNum2&quot; did not find a declaration.
&quot;test_code.cpp&quot;, line 42.6: 1540-1298 (I) &quot;var2 initNum2(float)&quot; 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
 
Also what version of AIX and what compiler version are you using?
 
Thanks flatwater. That post helped. I was having the same problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top