Hi, I have a struct function (struct 1) and I want to call another struct function (struct 2) from struct 1 using input of struct 1 itself. Basically :

  • Inside Struct Age, I need to calculate Age. And using conditional statement, if Age requirement is accepted --> Call struct Housing.
  • Struct Housing using input from 2 different structs, including struct Age (the caller struct). So I define struct Housing before struct Age.

Code is below :
This is the 1st struct
Code:
struct Salary salary (struct Hour hours)
{  //some calculation


    struct Salary result;
    result.S = S;
    return result;
}
This is the 2nd struct
Code:
struct Housing house (struct Salary sal, struct Age member)
{  //calculation & calling value sal.S (from struct Salary) 
     //and member.age (from struct Age)


    struct Housing result;
    result.D = D;
    return result;
}

And this is where I need to call struct inside conditional statement :
Code:
struct Age pass (struct Hour hours, int x, int y)
{   //some calculation
    
    if (fabs (a2-a1) < 5){
        printf("Age requirement - %3.f %3.f : PASS \n",x,y);
        struct Age result;
        result.age  = age;
        result.ret  = TRUE;
        return result;

        struct Housing H = house(salary, pass); //Error here
        //This struct call its own func (pass). 
    }
    
    //some false statements
}

However I encountered error :
Code:
Error : error: passing 'struct Salary (struct Hours)' to parameter of incompatible type 'struct Salary'
struct Housing H = house(salary, pass);
                         ^~~~~
passing argument to parameter 'sal' here
I hope my explanation isn't confusing. Where did I miss in my code ?