Skip to content

Line directive emitted in middle of multi-line string which contains an ifdef or ifndef #225

@njnobles

Description

@njnobles

Hi, I'm running into an issue where a line directive is being emitted in the middle of a multi-line string if there's an ifdef or ifndef directive in the middle of the string. The line directive was not emitted in Boost 1.77.0.
I suspect this issue was introduced in this PR: #140
After reverting that change, I no longer see line directives emitted in the middle of the multi-line string.
Here's an example to illustrate the issue:
test.cpp

"1
#ifdef A
    2a"
#else
    2b
    3"
#endif

The following are using default_preprocessing_hooks.
Boost 1.77.0 preprocessed output:

"1
    2 b
    3"

Boost 1.86.0 preprocessed output:

"1
    #line 5 "t_2_032.cpp"
2 b
    3"

Boost 1.86.0 output is identical to Boost 1.77.0 output if I revert #140

And for comparison, here's output from Visual Studio's cl.exe preprocessor:

#line 1 "test.cpp"
"1



    2b
    3"
#line 8 "test.cpp"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions