This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

No MULTIPLE CALL TO SEGMENT warning where it should be...

Please consider the following code.

//--- module main.c ---

...

void main() {
        ...
        set_status_word(...);
        ...
}

//--- module can.c ---

...

void CAN_int_handler(void) interrupt 7 {
        ...
        set_status_word(...);
        ...
}

//--- module utils.c ---

...

void set_status_word(...) {
        ...
}

If you replace the calls to set_status_word() with calls to printf(), the linker issues a "multiple call to segment" warning, but, like this, this code causes no warnings. Why not? I looked at the assembler output of the set_status_word() function and noticed that it isn't using absolute register addressing. Can this relate somehow?

Parents
  • unsigned int status_word;
    
    ...
    
    void set_status_word(unsigned int new_status_word)
    {
        status_word = new_status_word;
    }
    

    This should not give you an L15 error, since the function argument is passed in registers and the function has no local variables that are located in overlayed memory. The function is intrinsically reentrant. However:

    unsigned char array_idx;
    unsigned char array_data[4];
    
    void put_data_into_array(unsigned char input_data)
    {
      if(array_idx < 4)
      {
        array_data[array_idx++] = input_data;
      }
    }
    

    This doesn't produce an L15 error either, even though it is guaranteed to produce "unintended" behavior. It is the programmers job to recognize the potential source of trouble and eliminate it.

Reply
  • unsigned int status_word;
    
    ...
    
    void set_status_word(unsigned int new_status_word)
    {
        status_word = new_status_word;
    }
    

    This should not give you an L15 error, since the function argument is passed in registers and the function has no local variables that are located in overlayed memory. The function is intrinsically reentrant. However:

    unsigned char array_idx;
    unsigned char array_data[4];
    
    void put_data_into_array(unsigned char input_data)
    {
      if(array_idx < 4)
      {
        array_data[array_idx++] = input_data;
      }
    }
    

    This doesn't produce an L15 error either, even though it is guaranteed to produce "unintended" behavior. It is the programmers job to recognize the potential source of trouble and eliminate it.

Children