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 — #174 remove line markers from output using -P on the command line by driftregion · Pull Request #704 · cppcheck-opensource/simplecpp

Conversation

@driftregion

@driftregion driftregion commented Sep 24, 2026

Copy link
Copy Markdown

implements #174.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@driftregion
cppcheck-opensource#174 remove line markers from output using -P on t…
6c61400
…he command line
danmar
danmar reviewed Oct 1, 2026
View reviewed changes
Comment thread simplecpp.cpp
fileindex = location.fileIndex;

lineDirective(fileindex, line, location);
if (!dui.ignoreLineDirectives)

@danmar danmar Oct 1, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an AI review take it with a grain of salt. Please feel free to reject it by clicking on Resolve

I don't think this implements what #174 asks for. gcc -E -P suppresses the linemarkers in the output; it does not ignore #line directives in the input. In simplecpp the output markers come from TokenList::stringify(), which writes #line N "file" whenever the file changes or the line goes backwards. Those are untouched by this PR, so includes still produce markers:

$ cat a.h
int h;
$ cat m.c
#include "a.h"
int x;
#line 10 "foo.c"
int y;
$ ./simplecpp -P m.c

#line 1 "a.h"
int h ;
#line 2 "m.c"
int x ;

int y ;

Ignoring input #line also changes semantics in a way gcc's -P does not: __LINE__/__FILE__ and the locations in error messages no longer follow the #line directive (with gcc -E -P, #line 10 "foo.c" still affects __LINE__/__FILE__).

Suggestion: make this an output option instead, e.g. a parameter to stringify() (or a separate print loop in main.cpp) that skips writing the #line markers, and leave the tokenizer/DUI unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread simplecpp.cpp
}

auto *const data = new FileData {path, TokenList(path, filenames, {}, outputList)};
auto *const data = new FileData {path, TokenList(path, filenames, dui, outputList)};

@danmar danmar Oct 1, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an AI review take it with a grain of salt. Please feel free to reject it by clicking on Resolve

Passing dui here instead of {} changes behaviour for all library users, not just -P: readfile() uses dui.std for the #line portability diagnostics, so headers will now get std-specific messages they didn't get before. That may be a good change, but it is unrelated to -P. If the option becomes output-only (see the other comment), this change isn't needed. If it is kept, it would be good to mention it in the PR description and add a test for it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test.cpp
}


static void location13()

@danmar danmar Oct 1, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an AI review take it with a grain of salt. Please feel free to reject it by clicking on Resolve

This test only covers a #line directive in the main file. The more common case for -P (e.g. creduce input) is output that crosses #include boundaries, and that currently still prints #line markers. A test that uses an include, and checks that the stringified output has no #line lines, would catch that.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@driftregion driftregion mentioned this pull request Oct 1, 2026
add missing #line directive to misra.py cppcheck-opensource/cppcheck#8879
Open
@danmar

danmar commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

The CI failures are not caused by this PR. I have made a fix in the master branch. if you rebase your branch it should work.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@danmar danmar danmar left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@driftregion @danmar
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — 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.