Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
RENESAS TOOL NEWS on June 1, 2005: RSO-M3T-NC30WA_1-050601D

A Note on Using the C Compiler Packages
M3T-NC308WA and M3T-NC30WA
--On Using the labs and abs Functions--

Please take note of the following problem in using for the M32C series (M3T-NC308WA); and for the M16C series (M3T-NC30WA) of MCUs:
  • On using the labs and abs functions


  1. Versions Concerned
    M3T-NC30WA V.1.00 Release 1 ~ V.5.30 Release 02
    M3T-NC308WA V.1.00 Release 1 ~ V.5.40 Release 00

  2. Description
    Calculating an absolute value using the labs or abs function may result in an incorrect value being obtained.

    2.1 Conditions
    This problem occurs if the following conditions are all satisfied:
    (1) The standard header file stdlib.h is included.
    (2) The labs or abs function takes an expression as an argument.

    2.2 Example
    --------------------------------------------------------------------
    #include <stdlib.h>             /* Condition (1) */
    
    unsigned int b=10;
    unsigned int a=8;
    
    unsigned int result;
    void func(void)
    {
            result=abs(a - b);      /* Condition (2) */
    }
    --------------------------------------------------------------------


  3. Workaround
    After including stdlib.h, disable the labs macro using preprocessing directive #undef labs or disable the abs macro using preprocessing directive #undef.
    Example:
    --------------------------------------------------------------------
    #include <stdlib.h>
    #undef abs                       /* Disable abs macro */
    unsigned int b=10;
    unsigned int a=8;
    
    unsigned int result;
    void func(void)
    {
            result=abs( a-b );
    }
    --------------------------------------------------------------------


  4. Schedule of Fixing the Problem
    We plan to fix this problem in the next release of the product.





© 2008. Renesas Technology Corp., All rights reserved. Privacy | Legal