Page 1 of 1

MSVC succedded, but not gcc/clang

Posted: Sun Jan 19, 2020 7:07 am
by ONEEYEMAN
Hi, ALL,
Following code:

Code: Select all

       wxDataViewItem item = event.GetItem();
        m_itemPos = (int) item.GetID();
compiles successfully on MSVC 2017, but fails to compile on both gcc and clang.

I presume I'm doing something wrong, but I'm no sure what.

Could someone please help? I'm trying to get the information inside the wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, about the item being dragged (it's position).

Thank you.

Re: MSVC succedded, but not gcc/clang

Posted: Sun Jan 19, 2020 9:24 am
by Kvaz1r
And what's written in the compiler error?

Re: MSVC succedded, but not gcc/clang

Posted: Sun Jan 19, 2020 3:48 pm
by ONEEYEMAN
Hi,
gcc gives:
cast from 'wxItemId<void *>::Type (aka void * ) to int looses precision (-fpermissive)
Thank you.

Re: MSVC succedded, but not gcc/clang

Posted: Sun Jan 19, 2020 7:03 pm
by Kvaz1r
That's right. GetID returns pointer to void so in C++ you should explicitly cast it to your type. Example as usual you can see in dataview sample.

Re: MSVC succedded, but not gcc/clang

Posted: Sun Jan 19, 2020 7:19 pm
by ONEEYEMAN
Hi,
And I'm.

Code: Select all

m_itemPos = (int) item.GetID();
m_itemPos is of type int and I'm explicitly casting the result to the "int".

Unless there is another way of getting the item row for the item I'm dragging...

Anyway it should either fail everywhere or compile everywhere...

Thank you.

Re: MSVC succedded, but not gcc/clang

Posted: Sun Jan 19, 2020 8:19 pm
by Kvaz1r
Ah, right, I overlooked the question, sorry. SO gave such topic - https://stackoverflow.com/questions/202 ... -compiling
But I've not sure that it's the right way to get item row because ID used to get window id and not item row. Maybe ItemToRow ?