Skip to content

Preprocessor macro parsing does not accept a string token as an argument to the pasting operator #567

Open
@jeevesmkii

Description

@jeevesmkii

When a function type macro is defined with the pasting operator applied to string token the macro parser warns this is an invalid use of macro pasting.

An example of a valid macro rejected by Eclipse CDT 4.29.0 but accepted by compilers:

#include <string_view>
#include <iostream>

using namespace std::literals;

/* define a static C++ stringview by calling the sv operator */
#define STRVIEW(name, str) static constexpr std::string_view name = str ## sv

STRVIEW(k_foo, "stringview!");

int main()
{
std::cout << "stringview is " << k_foo << std::endl;
return 0;
}

Expected: should allow the string token to be concatenated with the literal sv to produce the operator call "stringview"sv.
Actual behaviour: rejects the concatenation as invalid.

Observed on Eclipse 2023.09 (4.29.0) on Ubuntu Linux with OpenJDK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    languageC/C++ Language Support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions