Post

Replies

Boosts

Views

Activity

C++14 integer literal separator causes AppleClang error
On AppleClang 14.0.0, this code... #include <iostream> #define EXPECT_EQ(x, y) int main() { const int foo = 6'765; std::cout << foo << '\n'; EXPECT_EQ(6'765, 6'765); } ...causes a compile error: test/src/main.cpp:8:19: warning: missing terminating ' character [-Winvalid-pp-token] const int foo = 6'765; ^ test/src/main.cpp:8:19: error: expected ';' at end of declaration const int foo = 6'765; ^ ; test/src/main.cpp:10:24: error: too few arguments provided to function-like macro invocation EXPECT_EQ(6'765, 6'765); ^ test/src/main.cpp:5:9: note: macro 'EXPECT_EQ' defined here #define EXPECT_EQ(x, y) ^ test/src/main.cpp:10:2: error: use of undeclared identifier 'EXPECT_EQ' EXPECT_EQ(6'765, 6'765); ^ With clang-16 out, clang-format now supports IntegerLiteralSeparator, which actively adds these digit separators on a codebase: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#integerliteralseparator By the way, according to cppreference.com, AppleClang should be supporting this: https://en.cppreference.com/w/cpp/compiler_support/14 Is this issue just for me, or does AppleClang really not work with these integer literal separators at the moment?
1
1
1.1k
Mar ’23
C++14 integer literal separator causes AppleClang error
On AppleClang 14.0.0, this code... #include <iostream> #define EXPECT_EQ(x, y) int main() { const int foo = 6'765; std::cout << foo << '\n'; EXPECT_EQ(6'765, 6'765); } ...causes a compile error: test/src/main.cpp:8:19: warning: missing terminating ' character [-Winvalid-pp-token] const int foo = 6'765; ^ test/src/main.cpp:8:19: error: expected ';' at end of declaration const int foo = 6'765; ^ ; test/src/main.cpp:10:24: error: too few arguments provided to function-like macro invocation EXPECT_EQ(6'765, 6'765); ^ test/src/main.cpp:5:9: note: macro 'EXPECT_EQ' defined here #define EXPECT_EQ(x, y) ^ test/src/main.cpp:10:2: error: use of undeclared identifier 'EXPECT_EQ' EXPECT_EQ(6'765, 6'765); ^ With clang-16 out, clang-format now supports IntegerLiteralSeparator, which actively adds these digit separators on a codebase: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#integerliteralseparator By the way, according to cppreference.com, AppleClang should be supporting this: https://en.cppreference.com/w/cpp/compiler_support/14 Is this issue just for me, or does AppleClang really not work with these integer literal separators at the moment?
Replies
1
Boosts
1
Views
1.1k
Activity
Mar ’23