mingw64 compilation fail

Bug #1180657 reported by sugeng anto
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Won't Fix
Undecided
Unassigned

Bug Description

Compilation using mingw64 on windows 7 64-bit is failed:

...common/class_layer_box_selector.cpp: In member function 'LAYER_NUM LAYER_BOX_SELECTOR::GetLayerSelection() const':
...common/class_layer_box_selector.cpp: 70:70: error: cast from 'void*' to 'long unsigned int' loses precision [-fpermissive]

perhaps this is because the pointer in 64-bit and 32-bit has different size.

thanks

Revision history for this message
Dick Hollenbeck (dickelbeck) wrote : Re: [Bug 1180657] [NEW] mingw64 compilation fail

On 05/16/2013 12:21 AM, sugeng anto wrote:
> Public bug reported:
>
> Compilation using mingw64 on windows 7 64-bit is failed:
>
> ...common/class_layer_box_selector.cpp: In member function 'LAYER_NUM LAYER_BOX_SELECTOR::GetLayerSelection() const':
> ...common/class_layer_box_selector.cpp: 70:70: error: cast from 'void*' to 'long unsigned int' loses precision [-fpermissive]
>
> perhaps this is because the pointer in 64-bit and 32-bit has different
> size.

Actually it is a bug in the compiler. This should be a warning at best. There is no
reason to dis-believe a cast.

(long unsigned int) is 32 bits. pointers are 64 bits. You can know that, put a cast in
there saying you don't care, and still get yelled at. That is a bug IMO.

Fix committed.

Revision history for this message
sugeng anto (anthos1984) wrote :

It resolved after 'long' is changed into 'intptr'.

However, another errors appear (after that on is passed). :
 in member function 'void EDA_LIST_DIALOG::Append(const wxArrayString&)
common/displlist.cpp:137:60: error: cast from 'const wxString*' to 'long int' loses precision
      m_listBox->SetItemData(itemIndex, (long) &(itemList[0]));

 in member function 'void EDA_LIST_DIALOG::InsertItems(const std::vector<wxArrayString>&, int)
common/displlist.cpp:160:84: error: cast from 'const wxString*' to 'long int' loses precision
      m_listBox->SetItemData(itemIndex, (long) &itemList[row].Item(col));

 in member function 'void EDA_LIST_DIALOG::SortList():
common/displlist.cpp:224:48: error: invalid conversion from 'int(*)(long int, long int, long int)' to 'wxListCtrlCompare {aka int (*)(long long int, long long int, long long int)}
      m_listBox->SortItems(MyCompareFunction, 0);

Also some warning :

in function 'MyCompareFunction(long int, long int, long int)
common/displlist.cpp:215:44: warning : cast to pointer from integer of different size
     wxString* component1Name = (wxString*) aitem1;
common/displlist.cpp:216:44: warning : cast to pointer from integer of different size
     wxString* component2Name = (wxString*) aitem2;

maybe this appear on linux-64 version too?

thanks

Revision history for this message
Dick Hollenbeck (dickelbeck) wrote : Re: [Bug 1180657] Re: mingw64 compilation fail

On May 24, 2013 6:40 PM, "sugeng anto" <email address hidden> wrote:
>
> It resolved after 'long' is changed into 'intptr'.
>
> However, another errors appear (after that on is passed). :
> in member function 'void EDA_LIST_DIALOG::Append(const wxArrayString&)
> common/displlist.cpp:137:60: error: cast from 'const wxString*' to 'long
int' loses precision
> m_listBox->SetItemData(itemIndex, (long) &(itemList[0]));
>
> in member function 'void EDA_LIST_DIALOG::InsertItems(const
std::vector<wxArrayString>&, int)
> common/displlist.cpp:160:84: error: cast from 'const wxString*' to 'long
int' loses precision
> m_listBox->SetItemData(itemIndex, (long) &itemList[row].Item(col));
>
> in member function 'void EDA_LIST_DIALOG::SortList():
> common/displlist.cpp:224:48: error: invalid conversion from 'int(*)(long
int, long int, long int)' to 'wxListCtrlCompare {aka int (*)(long long int,
long long int, long long int)}
> m_listBox->SortItems(MyCompareFunction, 0);
>
> Also some warning :
>
> in function 'MyCompareFunction(long int, long int, long int)
> common/displlist.cpp:215:44: warning : cast to pointer from integer of
different size
> wxString* component1Name = (wxString*) aitem1;
> common/displlist.cpp:216:44: warning : cast to pointer from integer of
different size
> wxString* component2Name = (wxString*) aitem2;
>
> maybe this appear on linux-64 version too?
>
> thanks

Can you make a patch?

What gcc version are you using?

>
> --
> You received this bug notification because you are a member of KiCad Bug
> Squad, which is subscribed to KiCad.
> https://bugs.launchpad.net/bugs/1180657
>
> Title:
> mingw64 compilation fail
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1180657/+subscriptions

Martin Errenst (imp-d)
tags: added: compilation windows
Revision history for this message
Nick Østergaard (nickoe) wrote :

I also see this error (or similar) when trying to cross compile on archlinux x86_64 with x86_64-w64-mingw32. What is the best possible action from here?

tags: added: mingw
xzcvczx (xzcvczx)
Changed in kicad:
status: New → Fix Released
Revision history for this message
Nick Østergaard (nickoe) wrote :

This does not seem to be an issue anymoe... at least it builds fine on mingw in msys2 both 32 and 64 bit.

Changed in kicad:
status: Fix Released → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.