GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Invalid ## usage when expanding · Issue #300 · cppcheck-opensource/simplecpp

Invalid ## usage when expanding  #300

New issue
Copy link
New issue
Copy link
Open
Open
Invalid ## usage when expanding #300
Copy link
Labels
bug

Description

@hobala
hobala
opened on Aug 7, 2023
Issue body actions

cppcheck 2.11 throws this error with the following code (Atmel ASF):

[FILE_LOCATION/ASF/common/utils/parts.h:63] (error) failed to expand 'SAM', Invalid ## usage when expanding 'SAM_PART_IS_DEFINED': Unexpected token ')' [preprocessorErrorDirective]

I think this is an error of simplecpp!

/* ! Check GCC and IAR part definition for 8-bit AVR */
#define AVR8_PART_IS_DEFINED(part) \\
	(defined(__ ## part ## __) || defined(__AVR_ ## part ## __))

/* ! Check GCC and IAR part definition for 32-bit AVR */
#define AVR32_PART_IS_DEFINED(part) \\
	(defined(__AT32 ## part ## __) || defined(__AVR32_ ## part ## __))

/* ! Check GCC and IAR part definition for SAM */
#define SAM_PART_IS_DEFINED(part) (defined(__ ## part ## __))
// ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/** @} */

Activity

  1. LorandMarton commented on Jan 6, 2024

    @LorandMarton
    LorandMarton
    on Jan 6, 2024
    More actions

    I also encounter the same problem.

  2. damorinCan commented on Jan 18, 2025

    @damorinCan
    damorinCan
    on Jan 18, 2025
    More actions

    Got the same issue when using cppcheck. Here some test code:

    #define AX  (A.X)
    #define AX2 (A.X2)
    
    #define Called(param)   do { param++; } while( 0 )
    #define Calling(param)  do { Called(param##2); while( 0 )
    
    typedef struct
    {
       int X;
       int X2;
    } SomeStruct;
    
    int test( void )
    {
       SomeStruct A;
    
       AX = 0;
       Calling(AX);
       return AX;
    }
    
    

    gcc -E:

    typedef struct
    {
       int X;
       int X2;
    } SomeStruct;
    
    int test( void )
    {
       SomeStruct A;
    
       (A.X) = 0;
       do { do { (A.X2)++; } while( 0 ); while( 0 );
       return (A.X);
    }
    

    simplecheck:
    ../cppcheck/abc.c:5: syntax error: failed to expand 'Calling', Invalid ## usage when expanding 'Calling': Unexpected token ')'

  3. firewave
    added
    bug
    on Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.