You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ 23%]: cache compiling.release dslings\en\cpp11\06-scoped-enums-1.cpp
error: dslings\en\cpp11\06-scoped-enums-1.cpp:52:26: error: found ':' in nested-name-specifier, expected '::'
52 | enum class Color8Bit : int8_t {
| ^
| ::
dslings\en\cpp11\06-scoped-enums-1.cpp:52:16: error: use of enum 'Color8Bit' without previous declaration
52 | enum class Color8Bit : int8_t {
| ^~~~~~~~~
dslings\en\cpp11\06-scoped-enums-1.cpp:52:35: error: qualified-id in declaration before '{' token
52 | enum class Color8Bit : int8_t {
| ^
In file included from dslings\en\cpp11\06-scoped-enums-1.cpp:17:
dslings\en\cpp11\06-scoped-enums-1.cpp:60:26: error: 'Color8Bit' was not declared in this scope
60 | d2x_assert_eq(sizeof(Color8Bit), sizeof(int8_t)); // Can customize type int8_t
| ^~~~~~~~~
./d2x/cpp/common.hpp:20:9: note: in definition of macro 'd2x_assert_eq'
20 | if (a != b) {
| ^
in dslings\en\cpp11\06-scoped-enums-1.cpp
error: exec(xmake build cpp11-06-scoped-enums-1) failed(-1), unknown reason
Activity
linyihai commentedon Jun 27, 2026
你好,上面是06-scoped-enums-1.cpp 题目报的错。我在linux上编译时通过的,换到windows上用其他编译器就会报错,并且错误会让新手摸不着头脑。我用deepseek建议我在头文件common.h 引入#include 解决
Sunrisepeak commentedon Jun 27, 2026
这个是一个练习故意留的错误, 需要你修复 (编译期计算f不能是运行时变量)
具体可以参考, 下面两个链接
linyihai commentedon Jun 27, 2026
贴错了,应该是这道题:06-scoped-enums-1.cpp
linyihai commentedon Jun 27, 2026
贴错了,应该是这道题:06-scoped-enums-1.cpp
Sunrisepeak commentedon Jun 28, 2026
可能需要加 std::int8_t 有些编译器, 你可以贴具体报错。如果你用std::init8_t ok 你可以改一下这个参考答案 PR 一下