Why Does the 'Sensor' Structure Cause Multiple Definition Errors in C?

  • Thread starter Thread starter Lancelot59
  • Start date Start date
  • Tags Tags
    Structure
Click For Summary
The discussion revolves around a C programming issue related to the definition and instantiation of a struct, specifically the `sensor_data` structure. The user encounters multiple definition errors due to the instantiation of the struct variable `Sensor` in the header file, which leads to global variable conflicts. It is clarified that struct definitions should be in header files, while instantiations should occur in source files to avoid such errors. The conversation also touches on the proper use of pointers and function prototypes when passing struct data, emphasizing that pointers should be used to modify struct data within functions. Ultimately, the user resolves their issues by adjusting the order of operations in their code and removing unnecessary global definitions.
  • #31
Alright then, so that's fixed. I'll try compiling it soon. I went though the function listing and there is no monitor function defined. So I'm not too sure where this is coming from.
 
Physics news on Phys.org
  • #32
Change the name of your monitor function.
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
3K