I have a pointer:
const float *m_posBufferPtr_float;
I assign to this variable with:
m_posBufferPtr_float = reinterpret_cast<const float *>(buffer()->data().constData());
At which constData()
function returns const char *
type:
inline const char *QByteArray::constData() const
{ return d->data(); }
Therefore my reinterpret_cast
should convert const char *
to const float *
.
But to my surprise, exactly before reinterpret_cast
my pointer is:
and exactly after reinterpret_cast
debugger shows my pointer as:
I wonder why reinterpret_cast
is converting const char *
to float
rather than const float *
If you take this snippet:
int main(int argc, char *argv[])
{
float* pointer = nullptr;
float value = 12.34;
pointer = &value;
qDebug() << *pointer;
}
and execute it step by step, you will see in your debugger:
Then
Notice that the type became float
when the pointer has been initialized. It's due to the configuration of the debugger.
In Qt Creator, right-click on your pointer and uncheck Dereference pointers automatically: