September 19, 2003

invalid reinterpret_cast

To read from files, I used to use

m_fs.read(reinterpret_cast(m_electlocs.begin()),m_nChannels*sizeof(ELECTLOC));
I'm not really sure what to do now, since the (new) compiler gives 'invalid reinterpret_cast'. Ok, I fixed it with
m_fs.read(reinterpret_cast(&m_electlocs[0]),m_nChannels*sizeof(ELECTLOC));
Apparently, the new gcc doesn't treat iterators so kindly. A simlar problem showed up when I tried to do
memcpy(m_event,&event2.Event1,sizeof(EVENT1));
In this case m_event is an iterator, and even though it technically is a pointer, the new gcc does not like it. I switched it to
memcpy(&(*m_event),&event2.Event1,sizeof(EVENT1));
and it worked. Which means I could have done &(*m_electlocs.begin()) though that is a lot uglier.

Posted by torque at September 19, 2003 12:43 PM | TrackBack
Comments
Post a comment









Remember personal info?