Menu

Problem with preprocessor

pozzugno
2022-08-24
2022-08-26
  • pozzugno

    pozzugno - 2022-08-24

    I tested the following source file:

    #include <stdio.h>
    
    #define __SAMC21N18A__
    #define SAM_PART_IS_DEFINED(part)       (defined(__ ## part ## __))
    
    #define SAM     SAM_PART_IS_DEFINED(SAMC21N18A)
    
    
    int main()
    {
    #if SAM
        printf("Hello World");
    #endif
    
        return 0;
    }
    

    gcc compiles it and the application shows "Hello World" as expected. However, when I analyze this file with cppcheck I obtain the following:

    cppcheck -E main.c
    
    int main ( )
    {
    
    return 0 ;
    }
    

    I'm using Cppcheck 2.8 under Windows. The macro SAM_PART_IS_DEFINED() is derived from a third party library from Atmel/Microchip. See here.

     
  • Daniel Marjamäki

    could you create a ticket here:
    https://github.com/danmar/simplecpp/issues

     

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.