cxx icon indicating copy to clipboard operation
cxx copied to clipboard

Dollar in identifier

Open Timmmm opened this issue 4 years ago • 1 comments

When compiling with Clang and -Weverything -Werror we get this error:

/path/to/analysis.h:935:36: error: '$' in identifier [-Werror,-Wdollar-in-identifier-extension]
#ifndef CXXBRIDGE1_STRUCT_somenamespace$SomeStruct

Apparently whether $ is allowed or not is implementation defined. (C++ 🤷 )

It would be nice if cxx could use something else instead of $ (maybe ____?) or alternatively add pragmas to disable that warning in the generated code for Clang.

For now we have just disabled that specific warning in our build system.

Timmmm avatar Feb 17 '21 15:02 Timmmm

We’ve run into the same thing. We moved the cxx-generated code into its own .a when possible, and generally down-scoped -Wno-dollar-in-identifier-extension as much as possible.

One problem with @Timmmm’s suggestion is that I think two or more _ would trigger-Wreserved-macro-identifier (https://en.cppreference.com/w/cpp/language/identifiers#In_declarations), but I’m also fine with the _Pragma approach.

sellout avatar May 10 '23 15:05 sellout