By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,588 Members | 1,920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,588 IT Pros & Developers. It's quick & easy.

error C2051: case expression not constant in VS2010

P: 3
Hi,

In one of the function we are using switch statement

as

switch
{

case HRESULT_FROM_WIN32( ERROR_INVALID_NAME ) :
}

The above code compiles fine in Vs2008 but its giving error when port to VS2010.

Error:error C2051: case expression not constant


Thanks in advance...

Regards,
Shyam
Aug 24 '10 #1
Share this Question
Share on Google+
1 Reply


100+
P: 687
the first hit in google for HRESULT_FROM_WIN32 (on msdn, unsurprisingly) contains this comment:

HRESULT_FROM_WIN32(x) used to be a macro, however we now run it as an inline function
// to prevent double evaluation of 'x'. If you still need the macro, you can use __HRESULT_FROM_WIN32(x)

And obviously result of function that is not constant can't be used as case label.
Aug 24 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.