filefn.h issue, after 2.8.12 -> 2.9.4 transition, using mingw-cross-compiler

53 views
Skip to first unread message

Alois Schlögl

unread,
Nov 14, 2012, 5:15:58 PM11/14/12
to wx-u...@googlegroups.com


In the past, I�ve been able to compiling the project stimfit with
mingw-cross-compiler http://mxe.cc/ using wxwidget 2.8.12. When I tried
to switch to 2.9.4, compiling wxWidget with mingw worked fine, but
compiling stimfit failed with the following error:


./stf.cpp:1:0: warning: -fPIC ignored for target (all code is position
independent) [enabled by default]
In file included from
.../usr/i686-static-mingw32/include/wx-2.9/wx/utils.h:21:0,
from .../usr/i686-static-mingw32/include/wx-2.9/wx/cursor.h:70,
from .../usr/i686-static-mingw32/include/wx-2.9/wx/event.h:22,
from .../usr/i686-static-mingw32/include/wx-2.9/wx/wx.h:25,
from ./stf.h:57,
from ./stf.cpp:24:
.../usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h: In function 'int
wxAccess(const wxString&, mode_t)':
.../usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h:504:46: error:
cannot convert 'const wxScopedCharBuffer {aka const
wxScopedCharTypeBuffer<char>}' to 'const wchar_t*' for argument '1' to
'int _waccess(const wchar_t*, int)'
.../usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h: In function 'int
wxOpen(const wxString&, int, mode_t)':
.../usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h:506:51: error:
cannot convert 'const wxScopedCharBuffer {aka const
wxScopedCharTypeBuffer<char>}' to 'const wchar_t*' for argument '1' to
'int _wopen(const wchar_t*, int, ...)'
.../usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h: In function 'int
wxStat(const wxString&, _stati64*)':
.../usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h:511:43: error:
cannot convert 'const wxScopedCharBuffer {aka const
wxScopedCharTypeBuffer<char>}' to 'const wchar_t*' for argument '1' to
'int _wstati64(const wchar_t*, _stati64*)'
.../usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h: In function 'int
wxLstat(const wxString&, _stati64*)':
.../usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h:513:44: error:
cannot convert 'const wxScopedCharBuffer {aka const
wxScopedCharTypeBuffer<char>}' to 'const wchar_t*' for argument '1' to
'int _wstati64(const wchar_t*, _stati64*)'
.../usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h: In function 'int
wxRmDir(const wxString&)':
.../usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h:515:39: error:
cannot convert 'const wxScopedCharBuffer {aka const
wxScopedCharTypeBuffer<char>}' to 'const wchar_t*' for argument '1' to
'int _wrmdir(const wchar_t*)'
.../usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h: In function 'int
wxMkDir(const wxString&, mode_t)':
.../usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h:519:39: error:
cannot convert 'const wxScopedCharBuffer {aka const
wxScopedCharTypeBuffer<char>}' to 'const wchar_t*' for argument '1' to
'int _wmkdir(const wchar_t*)'


I'm using the unicode version of wx-config; thus wxUSE_UNICODE is set.
After disabling the lines 504 to 519 in filefn.h (see patch below), I
could compile my project in the same way than with wxwidget2.8.


diff -U 5 usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h.orig
usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h
--- usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h.orig 2012-11-14
21:28:03.000000000 +0100
+++ usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h 2012-11-14
21:55:22.000000000 +0100
@@ -498,10 +498,11 @@
#endif
#ifndef wxFtell
#define wxFtell ftell
#endif

+#if !wxUSE_UNICODE
inline int wxAccess(const wxString& path, mode_t mode)
{ return wxCRT_Access(path.fn_str(), mode); }
inline int wxOpen(const wxString& path, int flags, mode_t mode)
{ return wxCRT_Open(path.fn_str(), flags, mode); }

@@ -521,10 +522,12 @@
inline int wxMkDir(const wxString& path, mode_t mode)
{ return wxCRT_MkDir(path.fn_str(), mode); }
#endif
#endif // !__WXWINCE__

+#endif //!wxUSE_UNICODE
+
#ifdef O_BINARY
#define wxO_BINARY O_BINARY
#else
#define wxO_BINARY 0
#endif


This is probably not the best solution, but I want to make you aware of
that issue. Or if I missed something, please let me know.


Alois


Vadim Zeitlin

unread,
Nov 15, 2012, 7:27:34 AM11/15/12
to wx-u...@googlegroups.com
On Wed, 14 Nov 2012 23:15:58 +0100 Alois Schlögl wrote:

AS> In the past, I’ve been able to compiling the project stimfit with
AS> mingw-cross-compiler http://mxe.cc/ using wxwidget 2.8.12. When I tried
AS> to switch to 2.9.4, compiling wxWidget with mingw worked fine, but
AS> compiling stimfit failed with the following error:

AFAICS your problem is with compiling wx/filefn.h itself, not really your
code at all. Could you please confirm that just compiling

#include <wx/filefn.h>

fail for you?

AS> .../usr/i686-static-mingw32/include/wx-2.9/wx/filefn.h:504:46: error:
AS> cannot convert 'const wxScopedCharBuffer {aka const
AS> wxScopedCharTypeBuffer<char>}' to 'const wchar_t*' for argument '1' to
AS> 'int _waccess(const wchar_t*, int)'

I don't understand this because fn_str() is supposed to return wchar_t*,
not wxScopedCharBuffer in Windows builds, including MinGW ones, see its
definition in wx/string.h and definition of wxMBFILES in wx/wxcrtbase.h.
Do you define __UNIX__ for your build by chance?

AS> This is probably not the best solution, but I want to make you aware of
AS> that issue. Or if I missed something, please let me know.

Well, no, removing all file-related functions is clearly not a good
solution.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

alois

unread,
Nov 15, 2012, 5:06:36 PM11/15/12
to wx-u...@googlegroups.com


Dear Vadim,


Yes, I can confirm that the problem was in compiling
   #include <wx/filefn.h>


Thanks for your hint about the __UNIX__ define.


Actually, the project used -D__LINUX__ as compile option. After removing it, and replacing it in the sources with the internal compiler macro __linux__, to problem went away.

Thank You very much for this very useful hint. This helped me a lot.


Alois
Reply all
Reply to author
Forward
0 new messages