MSVC succedded, but not gcc/clang

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4235
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

MSVC succedded, but not gcc/clang

Post by ONEEYEMAN » Sun Jan 19, 2020 7:07 am

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.

Kvaz1r
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 216
Joined: Tue Jun 07, 2016 1:07 pm

Re: MSVC succedded, but not gcc/clang

Post by Kvaz1r » Sun Jan 19, 2020 9:24 am

And what's written in the compiler error?

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4235
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: MSVC succedded, but not gcc/clang

Post by ONEEYEMAN » Sun Jan 19, 2020 3:48 pm

Hi,
gcc gives:
cast from 'wxItemId<void *>::Type (aka void * ) to int looses precision (-fpermissive)
Thank you.

Kvaz1r
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 216
Joined: Tue Jun 07, 2016 1:07 pm

Re: MSVC succedded, but not gcc/clang

Post by Kvaz1r » Sun Jan 19, 2020 7:03 pm

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.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4235
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: MSVC succedded, but not gcc/clang

Post by ONEEYEMAN » Sun Jan 19, 2020 7:19 pm

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.

Kvaz1r
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 216
Joined: Tue Jun 07, 2016 1:07 pm

Re: MSVC succedded, but not gcc/clang

Post by Kvaz1r » Sun Jan 19, 2020 8:19 pm

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 ?

Post Reply