Menu

1.75 New (wrong) information message for missing function (but is a macro)

versat
2016-08-08
2016-08-09
  • versat

    versat - 2016-08-08

    For code like this:

    #define BUTTON_PORT_NUMBER 2
    #define BTN_PIEZO_PIN (0x04)
    
    /// Helper macro to concatenate the parameters
    #define CONCATENATOR(x, y) x ## y
    /// Helper macro to evaluate the parameters before concatenating
    #define EVALUATOR(x, y) CONCATENATOR(x, y)
    /// Helper macro to evaluate button port number and add it to 'P'
    #define BUTTON_PORT EVALUATOR(P, BUTTON_PORT_NUMBER)
    
    /// Direction port for button
    #define BUTTON_PORT_DIR  (EVALUATOR(BUTTON_PORT, DIR))
    
    void func(void)
    {
        BUTTON_PORT_DIR &= (uint8_t)(~BTN_PIEZO_PIN);
    }
    

    I get the message:
    Id: checkLibraryFunction
    Summary: --check-library: There is no matching configuration for function EVALUATOR()
    wherever i use BUTTON_PORT_DIR.
    Maybe an issue with the new preprocessor?
    For the exact same code with 1.74 there was no such message.
    Is it worth a ticket?

    Regards
    Sebastian

     
  • Daniel Marjamäki

    Please try cppcheck -E

    cppcheck -E file.c
    

    If that output looks wrong, for instance if EVALUATOR is not expanded, please open an issue in the simplecpp issue tracker:

    https://github.com/danmar/simplecpp/issues

     
  • versat

    versat - 2016-08-09

    The output with -E for the above code is:

    void func ( void )
    {
     (  EVALUATOR(P,2)DIR  ) &= ( uint8_t ) ( ~  (  0x04  ) ) ;
    }
    

    EVALUATOR is only expanded once.
    I will create an issue for this.

     
  • versat

    versat - 2016-08-09
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.