S
snnn
Compiler error occurred when try to use a flexible template expression
in preprocessor defines
When I try to compile the following codes piece under Visual C++ .net
2003, I get an error "Fatal Error C1017"
typedef ::Loki::Typelist<int,::Loki::NullType> TList;
#if ::Loki::TL::Length<TList>::value
int x;
#endif
Fatal Error C1017:
invalid integer constant expression
The expression in an #if directive did not exist or did not evaluate to
a constant.
::Loki::TL::Length<TList> is a struct some like this:
struct Length{
enum { value=0}; // Indeed,the value should be the length of this
Typelist(TList)
}
emmm. try to the following one instead:
enum {value=::Loki::TL::Length<TList>::value};
#if value
int x;
#endif
Ok! No error, no warning. However, as you see, that's badly! I do not
need this extra enum value.
So, Help me, please! Where is the syntax error in the former case?
Thanks!
Thanks!
Thanks!
in preprocessor defines
When I try to compile the following codes piece under Visual C++ .net
2003, I get an error "Fatal Error C1017"
typedef ::Loki::Typelist<int,::Loki::NullType> TList;
#if ::Loki::TL::Length<TList>::value
int x;
#endif
Fatal Error C1017:
invalid integer constant expression
The expression in an #if directive did not exist or did not evaluate to
a constant.
::Loki::TL::Length<TList> is a struct some like this:
struct Length{
enum { value=0}; // Indeed,the value should be the length of this
Typelist(TList)
}
emmm. try to the following one instead:
enum {value=::Loki::TL::Length<TList>::value};
#if value
int x;
#endif
Ok! No error, no warning. However, as you see, that's badly! I do not
need this extra enum value.
So, Help me, please! Where is the syntax error in the former case?
Thanks!
Thanks!
Thanks!