c++ - GCC 4.2.2 unsigned short error in casting -


this line of code isn't compiling me on gcc 4.2.2

m_pout->m_r[i][j] = min(max(unsigned short(m_pin->m_r[i][j]), 0), ((1 << 15) - 1)); 

error: expected primary-expression before ‘unsigned’

however if add braces (unsigned short) works fine.

can please explain type of casting (allocation) being done here?

why isn't lexical parser/compiler able understand c++ code in gcc?

can suggest "better" way write code? supporting gcc 4.2.2 (no c++11, , cross platform)

i think bathsheba's answer @ least misleading. short(m_pin->m_r[i][j]) cast. why unsigned messing things up? it's because unsigned short not simple-type-specifier. cast syntax t(e) works if t single token, , unsigned short 2 tokens.

other types spelled more 1 token char* , int const, , therefore these not valid casts: char*(0) , int const(0).

with static_cast<>, < > balanced type can named sequence of identifiers, static_cast<int const*const>(0)


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -