This works in xcode, but not visual studio. The error is
error C2236: unexpected ‘enum’ ‘abc::def::`anonymous-namespace’::’. Did you forget a ‘;’?
I can’t figure out what is wrong.
namespace abc {
namespace def {
namespace {
long long enum {
aaa = 1L,
bbb = 2L,
};
}
}
}
PlasmaHH
15.5k5 gold badges43 silver badges57 bronze badges
asked Oct 16, 2011 at 20:23
4
That syntax is bizarre, I don’t see how it would work anywhere (EDIT: apparently it’s a GCC extension — thanks @PlasmaHH). This is the portable C++11 syntax you want:
enum : long long {
aaa = 1LL,
bbb = 2LL
};
answered Oct 16, 2011 at 20:25
ildjarnildjarn
61.7k9 gold badges125 silver badges210 bronze badges
This works in xcode, but not visual studio. The error is
error C2236: unexpected ‘enum’ ‘abc::def::`anonymous-namespace’::’. Did you forget a ‘;’?
I can’t figure out what is wrong.
namespace abc {
namespace def {
namespace {
long long enum {
aaa = 1L,
bbb = 2L,
};
}
}
}
PlasmaHH
15.5k5 gold badges43 silver badges57 bronze badges
asked Oct 16, 2011 at 20:23
4
That syntax is bizarre, I don’t see how it would work anywhere (EDIT: apparently it’s a GCC extension — thanks @PlasmaHH). This is the portable C++11 syntax you want:
enum : long long {
aaa = 1LL,
bbb = 2LL
};
answered Oct 16, 2011 at 20:25
ildjarnildjarn
61.7k9 gold badges125 silver badges210 bronze badges
I’m getting a compiler error on FreeBSD:
error: invalid combination of multiple type-specifiers
From the C++ Code:
typedef unsigned off_t uoff_t;
Not sure what the gcc compiler is trying to tell me.
asked Oct 23, 2010 at 18:29
![]()
WilliamKFWilliamKF
40.2k65 gold badges191 silver badges291 bronze badges
Unless off_t is a macro, it’s simply a syntax error.
unsigned is not something you can add to a typedef’ed type or use to modify such a type.
Cheers & hth.,
answered Oct 23, 2010 at 18:34
![]()
Use typedef std::make_unsigned_t< off_t > uoff_t; since C++14 instead to achieve the desired effect.
Use typedef std::make_unsigned< off_t >::type uoff_t; since C++11.
Use typedef boost::make_unsigned< off_t >::type uoff_t; before C++11.
answered Oct 23, 2010 at 18:41
I’m getting a compiler error on FreeBSD:
error: invalid combination of multiple type-specifiers
From the C++ Code:
typedef unsigned off_t uoff_t;
Not sure what the gcc compiler is trying to tell me.
asked Oct 23, 2010 at 18:29
![]()
WilliamKFWilliamKF
40.2k65 gold badges191 silver badges291 bronze badges
Unless off_t is a macro, it’s simply a syntax error.
unsigned is not something you can add to a typedef’ed type or use to modify such a type.
Cheers & hth.,
answered Oct 23, 2010 at 18:34
![]()
Use typedef std::make_unsigned_t< off_t > uoff_t; since C++14 instead to achieve the desired effect.
Use typedef std::make_unsigned< off_t >::type uoff_t; since C++11.
Use typedef boost::make_unsigned< off_t >::type uoff_t; before C++11.
answered Oct 23, 2010 at 18:41
Недопустимая комбинация спецификаторов типа?
Это работает в xcode, но не в Visual Studio. Ошибка
ошибка C2236: неожиданное перечисление abc :: def :: `анонимное пространство имен ‘::’. Вы забыли ‘;’?
Я не могу понять, что случилось.
namespace abc {
namespace def {
namespace {
long long enum {
aaa = 1L,
bbb = 2L,
};
}
}
}
Этот синтаксис странный, я не понимаю, как он будет работать где угодно (РЕДАКТИРОВАТЬ: очевидно, это расширение GCC — спасибо @PlasmaHH). Это переносимый синтаксис C ++ 11, который вам нужен:
enum : long long {
aaa = 1LL,
bbb = 2LL
};
ответ дан 16 окт ’11, 21:10
Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками
c++
visual-studio-2010
namespaces
compiler-errors
c++11
or задайте свой вопрос.
|
grosssmile 1 / 1 / 0 Регистрация: 26.09.2012 Сообщений: 37 |
||||
|
1 |
||||
|
27.09.2012, 23:11. Показов 48474. Ответов 5 Метки нет (Все метки)
ошибки:
__________________
0 |
|
alsav22 5493 / 4888 / 831 Регистрация: 04.06.2011 Сообщений: 13,587 |
||||||||
|
27.09.2012, 23:20 |
2 |
|||||||
3 |
|
Gepar 1186 / 542 / 78 Регистрация: 01.07.2009 Сообщений: 3,517 |
||||||||
|
28.09.2012, 11:43 |
3 |
|||||||
|
int автоматически подставлялся к любой функции где не указан тип возврата только в си.
при компиляции компилятор сам всё подставлял и получалось на выходе
и всё было окей
1 |
|
Герц 527 / 344 / 12 Регистрация: 05.11.2010 Сообщений: 1,076 Записей в блоге: 1 |
||||
|
28.09.2012, 13:16 |
4 |
|||
|
Не по теме: У тебя же точно написано, в чем проблема, дважды щелкнул по строчке с ошибкой — и тебе даже покажут, где именно в редакторе находится проблемная строка.
А где ты такой пример взял, что у тебя main без типа?
0 |
|
1186 / 542 / 78 Регистрация: 01.07.2009 Сообщений: 3,517 |
|
|
28.09.2012, 17:57 |
5 |
|
А где ты такой пример взял, что у тебя main без типа? Логично что в какой-то старой книге по си рекомендованной преподавателем в которой, как они любят говорить «ничего с тех пор не изменилось».
0 |
|
1 / 1 / 0 Регистрация: 26.09.2012 Сообщений: 37 |
|
|
28.09.2012, 19:04 [ТС] |
6 |
|
Логично что в какой-то старой книге по си рекомендованной преподавателем в которой, как они любят говорить «ничего с тех пор не изменилось». Именно так оно и было.
0 |
