error when called function is in the same .c file

General discussion on mikroC.
Post Reply
Author
Message
EESL
Posts: 12
Joined: 04 Feb 2019 15:30

error when called function is in the same .c file

#1 Post by EESL » 02 Dec 2019 18:46

Hello

I am not getting my Head around a problem that came up all ready last week.

I have a structure which i can pass along by value without problem to any function i want to anywhere in the project (multiple .c Files). interestingly enough when i try to pass the structure by ref via a pointer i can do that just to functions outside the calling functions .c file. how that problem actually came up is because i wrote some code in a .c file i use for developing. once i am finished with a part i move it to the actual file which shall be used in the end. therefore i move the definitions of the function to the header file where it should reside to be found and the function body to the .c file. interestingly enough at that moment the call signature throws an error. if i leave the function in another .c file (with its own header file which is included in both .c files) it works without problems. anyone can shine some light on that problem?
Two .c files: Screens.c and Developer_File.c
Two .h files: Screens.h and Developer_File.h

Code: Select all

//the structure could be something like that:
struct Test{
  unsigned int sibox1;
  unsigned int sibox2;
};

// Screens.c has Developer_File.h included where I had during the development this definition 

void manipulate_object_2(struct Test *obj);

//and in the Developer_File.c the function (this is now purely a dummy function) 

void manipulate_object_2(struct Test *obj){
  obj->sibox1= 425;
  obj->sibox2= 470;
}


//from Screens.c i can call after 
 
Struct Test hobj;

//without any problems:

manipulate_object_2(& hobj); 

//and there is no problem.  but if i move the function to the Screens.c file and the definition to the Screens.h File, commenting out in the Developer_File.c and Developer_File.h the function declarations and body i get an error…

// 438 Call signature does not match the function definition signature 'manipulate_object_2' Screens.c

calling the same type of function but not via a pointer but with a copy works also always. also a variable Int for example i can pass along with pointer inside the same .c file. but no luck with passing a struct pointer to a function when the function is in the same .c file.

Code: Select all

// this works wherever the function is no problems here...

//calling:
manipulate_object_2( hobj);

//when the function is built in this way...

void manipulate_object_2(struct Test obj); // in the .h File

void manipulate_object_2(struct Test obj){// in the .c File

  obj.sibox1 = 425;
  obj.sibox2 = 470;

}



I do not understand...

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: error when called function is in the same .c file

#2 Post by filip » 20 Dec 2019 12:54

Hi,

I apologize for the late reply, can you please attach a minimal project that demonstrates this issue ?

Regards,
Filip.

Post Reply

Return to “mikroC General”