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 — expandHashHash(): function-like macro not expanded when '(' is not adjacent (PAR-style indirection) · Issue #656 · cppcheck-opensource/simplecpp

expandHashHash(): function-like macro not expanded when '(' is not adjacent (PAR-style indirection) #656

New issue
Copy link
New issue
Copy link
Open
#655
Open
expandHashHash(): function-like macro not expanded when '(' is not adjacent (PAR-style indirection)#656
#655
Copy link
Labels
bug

Description

@paulafy6
paulafy6
opened on May 28, 2026
Issue body actions

When ## concatenation produces a function-like macro name but the argument list (...) is not immediately adjacent in the replacement text (hidden behind a secondary macro parameter), simplecpp aborts expansion and emits the concatenated token bare.

Reproducer

#define PAR(a, ...) a __VA_ARGS__
#define PREFIX_SCALAR(T, N) T N
#define DISPATCH(kind, ...) PAR(PREFIX_ ## kind, (__VA_ARGS__))
DISPATCH(SCALAR, int, x)

Expected:

int x

Actual:

1:
2:
3:
4: PREFIX_SCALAR ( int , x )

Root cause

expandHashHash() checks only B->next->op == '(' immediately after the ## result. In the PAR pattern, B->next is , (not (), so the function-like expansion is skipped.

Fix

A forward-scan fallback in the appendTokens context (expandResult==false) walks ahead on the same line, skipping , separators and resolving named parameter tokens via expandArg(), until ( is found.

PR attached: #655

Activity

  1. firewave
    added
    bug
    on May 28, 2026
  2. firewave commented on May 28, 2026

    @firewave
    firewave
    on May 28, 2026
    Collaborator
    More actions

    I am not seeing the unknownMacro mentioned in the report (that is a Cppcheck error) so I updated the expected output.

  3. danmar
    linked a pull request that will close this issueFix: simplecpp ## fails to expand function-like macro when '(' is not adjacent #655on Jun 2, 2026
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.