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

Linker warning L16

Hello,
While building a project this message appears:

*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
    SEGMENT: ?CO?AMPL_DRIVER

I know that this warning indicates that there is a part of code
in the ampl_driver file that is excluded from the overlay process.

after searching (by commenting code parts) I found out that the warning is caused from a
constant 'ref_int_tmpr', which is declared at the 'ampl_driver' file and
is used only once in the same file and nowhere else in the project.
The constant is used by a function which is included only if defined earlier:


// global declaration:
const float code ref_int_tmpr = 40;

...

#ifdef __LT
  out_sig[i] = (out_sig[i] / get_RAM_gain_factor(ampl_param.working_gain)) -
               low_temperature_correction(case_temperature,t_index,i);
#else
  if(!sensor_mode.delta)
  {
        //signal with temperature correction
        out_sig[i] = (out_sig[i] / get_RAM_gain_factor(ampl_param.working_gain)) *
                     ((1 + ref_int_tmpr * ID1_xram.alpha[i]) /
                     (1 + get_temp_sensor() * ID1_xram.alpha[i]));
  }//if(!sensor_mode.delta
  else
  {
        //no temperature correction
        out_sig[i] = out_sig[i] / get_RAM_gain_factor(ampl_param.working_gain);
  }
#endif //__LT

When the _LT option is defined (the #else part isn't executed) the error appears.
The problem is that the warning stays also after commenting/ entering into
the define choice the declaration part:

#ifndef __LT
    const float code ref_int_tmpr = 40
#endif

Any idea why?
Thanks,
Amitai

  • maybe the compiler is inlining the value? after all, it is a constant. could be a define anyway and then that store in a code segment wouldn't be required.

  • Take a look to the MAP file and identify the size of the segment.
    I believe you might have more than just this variable.

    You may then use the compiler listing (using the SYMBOLS option) to identify which other symbols are allocated to that segment.

  • Take a look to the MAP file and identify the size of the segment.
    I believe you might have more than just this variable.

    You may then use the compiler listing (using the SYMBOLS option) to identify which other symbols are allocated to that segment.

  • I found out that the warning is caused from a
    constant 'ref_int_tmpr', which is declared at the 'ampl_driver' file

    You've proved yourself that this conclusion is wrong. Because if had been correct, then #ifdef'ing the definition of 'ref_int_tmpr' would have got rid of the warning.

    The "uncalled segment" warning is issued for exactly the stated reason: you have a segment that's never called. Close to 100% of the time, that means there is an entire function which was compiled and linked in, but never called by the rest of the program; at least not in any way the compiler could find. That means you could have #ifdef'ed out that function and because of the way it affects overlaying, you really should.

    In your code sample, the most likely candidate for such a to-be-removed function would be get_temp_sensor().

  • Thanks for all the responses,

    in the map file the memory size details are:

    ...
    CODE    0033H     0003H     ABSOLUTE
    CODE   0036H   0004H    UNIT         ?CO?AMPL_DRIVER
    CODE    003AH     0001H     UNIT         ?PR?MEAS_PROCESS_PROC_INIT?MEAS_PROCESS_PROC
    ...
    

    The size of the ?CO?AMPL_DRIVER is 4 bytes which is the size of the
    const float code ref_int_tmpr.

    Trying to comment/enter to #ifdef any of the functions and variables
    concerning the ref_int_tmpr doesn't remove the warning.
    The only thing that does remove the warning is referring
    to the ref_int_tmpr out of the '#else' statement, for example:

    
    float xdata tempPar;    // for test purpose
    
    ...
    
     #ifdef __LT            // 14.10.15 - Amitai
            // photo signal calculation with
            // temperature correction for low temperature camera
            out_sig[i] = (out_sig[i] / get_RAM_gain_factor(ampl_param.working_gain)) -
                     low_temperature_correction(case_temperature,t_index,i);
    
                 tempPar = ref_int_tmpr;  
    
     #else
            if(!sensor_mode.delta)
            {
            //signal with temperature correction
            out_sig[i] = (out_sig[i] / get_RAM_gain_factor(ampl_param.working_gain)) *
                     ((1 + ref_int_tmpr * ID1_xram.alpha[i])
                      (1 + get_temp_sensor() * ID1_xram.alpha[i]));
            }//if(!sensor_mode.delta
            else
            {
            //no temperature correction
                    out_sig[i] = out_sig[i] / get_RAM_gain_factor(ampl_param.working_gain);
            }
    #endif //__LT
    
    

  • If this is the case, then the variable is perhaps defined several times.

    I suggest that you verify the AMPL_DRIVER C source file with:

    - create a PREPRINT file that contains the source code after the pre-processor run. You can then find 'const' or 'code' variables that the compiler sees.

    - create a list file with the SYMBOLS directive. Then review the variables listed in the LST output file of the compiler.

  • If I understood correctly what to check, these are the results:

    - in the ampl_driver.i file:

    
    #line 29 "ampl_driver.c" /0
    
     const float code low_photo_signal = 0.0;
    
     float xdata tempPar;
    
    

    searching the file for other relevant 'code' and 'ref_int_tmpr'
    didn't result in anything.

    - in the ampl_driver.lst file:

    declaration part:

     25
     26          #ifndef __LT
                              const float code ref_int_tmpr = 40;
                  #endif
     29
     30          const float code low_photo_signal = 0.0;
     31
     32          float xdata tempPar;            // fot test perpuose
    
    ...
    ...
    
    afterwards:
    
    175   2                      #ifdef __LT             // 14.10.15 - Amitai
    176   2                              // photo signal calculation with
    177   2                              // temperature correction for low temperature camera
    178   2                              out_sig[i] = (out_sig[i] /   get_RAM_gain_factor(ampl_param.working_gain)) -
    179   2                                       low_temperature_correction(case_temperature,t_index,i);
    180   2                      #else
                                          if(!sensor_mode.delta)
                                          {
                                                  //signal with temperature correction
                                                  out_sig[i] = (out_sig[i] / get_RAM_gain_factor(ampl_param.working_gain)) *
                                                                           ((1 + ref_int_tmpr * ID1_xram.alpha[i]) /
                                                                            (1 + get_temp_sensor() * ID1_xram.alpha[i]));
                                          }//if(!sensor_mode.delta
                                          else
                                          {
    C51 COMPILER V9.54   AMPL_DRIVER                                                           10/20/2015 12:06:29 PAGE 31
    
                                                  //no temperature correction
                                                  out_sig[i] = out_sig[i] / get_RAM_gain_factor(ampl_param.working_gain);
                                          }
                                  #endif //__LT
     194   2              }//for(i=0; i<COMMON_NUM; i++)
     195   1              return OK_SerialOut;
     196   1      }
    
    

    no 'ref_int_tmpr' in symbols section of file.

    So it seems that the compiler ignores the content which is not defined currently,
    but why is an error appearing? on the other hand changing the definition so that __LT isn't defined results with no
    errors.

    Thanks,
    Amitai

  • Is the variable low_photo_signal used somewhere?

  • The issue is that the compiler/linker cannot distinguish between individual variables.
    The linker just deals with segments and when there is no reference to a segment the warning 16 is omitted.

    If you access one of the variables that warning 16 disappears.

  • The problem was with the
    const float code low_photo_signal = 0.0;
    which is not used in the whole program.
    Thanks for all the help,
    Amitai