Skip to content

Conversation

@dbartolini
Copy link
Contributor

First preprocess pass now preserves comments so they can be returned later if requested. Since shaderc now has to deal with comments that may contain identifiers, a new strFindUncommented() has been introduced to only match strings when they appear outside C/C++ style comments.

One issue is that fcpp when used with FPPTAG_KEEPCOMMENTS gets confused on $input/output lines if those contain unspaced comments:

$ ./fcpp -C -V test_nosp.c 

#line 1 "test_nosp.c"
$input v_wpos, // comment
v_texcoord0
$input v_wpos, /* comment */v_texcoord0

$ cat test_nosp.c 
$input v_wpos, v_texcoord0// comment
$input v_wpos, v_texcoord0/* comment */

Adding a space fixes the issue:

$ ./fcpp -C -V test.c 

#line 1 "test.c"
$input v_wpos, v_texcoord0// comment

$input v_wpos, v_texcoord0/* comment */

$ cat test.c 
$input v_wpos, v_texcoord0 // comment
$input v_wpos, v_texcoord0 /* comment */

That is why fs_bump.sc has been changed. Not sure if you want this fixed and whether on fcpp or shaderc.

@dbartolini dbartolini requested a review from bkaradzic as a code owner January 9, 2026 07:33
@bkaradzic
Copy link
Owner

Not sure if you want this fixed and whether on fcpp or shaderc.

It seems like fcpp issue, and it should be fixed there.

// substituting code.
// First preprocess pass always keep all comments.
// They will be stripped later unless keepComments is enabled.
preprocessor.setKeepComments(true);
Copy link
Owner

Choose a reason for hiding this comment

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

Why not only keep them if keepComments is enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@dbartolini dbartolini force-pushed the shaderc-keepcomments branch from 1557a35 to 5b57e2c Compare January 9, 2026 07:59
@dbartolini
Copy link
Contributor Author

Not sure if you want this fixed and whether on fcpp or shaderc.

It seems like fcpp issue, and it should be fixed there.

I'll fix it there and update this PR afterwards.

@bkaradzic bkaradzic merged commit 7e518d0 into bkaradzic:master Jan 9, 2026
10 checks passed
@dbartolini dbartolini mentioned this pull request Jan 9, 2026
@dbartolini dbartolini deleted the shaderc-keepcomments branch January 9, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants