2.9.1 VS 2008 Windows 7 64 bit 'mode_t' : redefinition

732 views
Skip to first unread message

neil

unread,
Aug 30, 2010, 11:52:36 PM8/30/10
to wx-users
Hi,
I'm migrating an application from XP to windows 7 using wxwidgets
2.8.10. I had a few errors so decided to migrate the application to
wxwidgets 2.9.1 as I believe this is compatible with windows 7. I am
able to build wxwidgets, but during the compilation of my application
code I get the following error:

C:\MILXView-win32-depend\itk-3.16.0\Utilities\itksys/
SystemTools.hxx(48) : error C2371: 'mode_t' : redefinition; different
basic types
13> C:\MILXView-win32-depend\wxWidgets-2.9.1\include\wx/
filefn.h(98) : see declaration of 'mode_t'

Searching on the internet I found (http://trac.wxwidgets.org/ticket/
11429) which states "typedef int mode_t;" modify "#define mode_t int".
However if I do this I can no longer build wxwidgets I get many errors
such as:

6>C:\MILXView-win32-depend\wxWidgets-2.9.1\include\wx/filefn.h(568) :
error C2143: syntax error : missing ')' before ';'
6>C:\MILXView-win32-depend\wxWidgets-2.9.1\include\wx/filefn.h(568) :
error C2059: syntax error : ')'
6>C:\MILXView-win32-depend\wxWidgets-2.9.1\include\wx/filefn.h(569) :
error C2470: 'mode' : looks like a function definition, but there is
no parameter list; skipping apparent body
6
... etc

I am using Visual Studio 2008 on windows 7 64 bit machine. I also have
an error that compiled okay on XP win32 wxwidgets 2.8.10:

error C2450: switch expression of type 'wxUniChar' is illegal
Ambiguous user-defined-conversion

for the following code:

bool milxFileName::IsVariableFormat( const wxString &pattern )
{
for( unsigned int i=0; i<pattern.length(); i++ ) {
if( pattern[i] == '%' && i < pattern.length()-1 ) {
switch( pattern[i+1] ) {
case 'd': case 'e': case 'f': return true;
}
}
}
return false;
}


the line causing the error is:

switch( pattern[i+1] ) {

Any help would be much appreciated

Neil

Vadim Zeitlin

unread,
Aug 31, 2010, 4:31:43 AM8/31/10
to wx-u...@googlegroups.com
On Mon, 30 Aug 2010 20:52:36 -0700 (PDT) neil <burd...@yahoo.co.uk> wrote:

n> C:\MILXView-win32-depend\itk-3.16.0\Utilities\itksys/
n> SystemTools.hxx(48) : error C2371: 'mode_t' : redefinition; different
n> basic types
n> 13> C:\MILXView-win32-depend\wxWidgets-2.9.1\include\wx/
n> filefn.h(98) : see declaration of 'mode_t'
n>
n> Searching on the internet I found (http://trac.wxwidgets.org/ticket/
n> 11429) which states "typedef int mode_t;" modify "#define mode_t int".

Do you use ACE too or is there some other reason you can't avoid defining
mode_t yourself in SystemTools.hxx?

n> However if I do this I can no longer build wxwidgets I get many errors
n> such as:
n>
n> 6>C:\MILXView-win32-depend\wxWidgets-2.9.1\include\wx/filefn.h(568) :
n> error C2143: syntax error : missing ')' before ';'

I don't see how could this caused by replacing typedef with #define. Are
you sure you didn't make some typo elsewhere when doing it? Comparing your
modified version with the original one using diff could be useful.

Anyhow, the real solution to #11429 is to do what I wrote in my comment
there, i.e. wrap mode_t definition in "#if wxNEEDS_MODE_T" test and
predefine wxNEEDS_MODE_T as 0 for projects, such as yours, that already
define mode_t.

n> I am using Visual Studio 2008 on windows 7 64 bit machine. I also have
n> an error that compiled okay on XP win32 wxwidgets 2.8.10:
n>
n> error C2450: switch expression of type 'wxUniChar' is illegal
n> Ambiguous user-defined-conversion

This is one of the few known problems with the Unicode-related changes.
You really, really ought to read about them in the manual. In particular,
this one is the very first in the list at

http://docs.wxwidgets.org/2.9.1/overview_unicode.html#overview_unicode_compilation_errors

Regards,
VZ

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

neil

unread,
Sep 1, 2010, 12:10:13 AM9/1/10
to wx-users
Cool, thanks for that.

Note: I initially tried to build wxWidgets 2.9.1 using wx_vc9.sln, but
found that the build order was wrong so had to run the build several
times to get everything to build. I aslo tried using wx_dll.dsw which
proved successful immediately so I assume the build order is correct
here.

However, when linking against my application code the libraries tried
to look in ~/lib/vc_amd64_dll, but wxWidgets had created a directory
named vc_dll. So to solve the issue I just renamed the directory. Are
you aware of this issue? Or did I miss out a configuration step. Also
the wx_dll.dsw didn't build the wxmsw29ud_ribbon.lib so had to build
it via the wx_vc9.sln as ribbon was not part of the wx_dll.dsw
solution. easy fixes just wondered if you had encountered them?

Thanks again
Neil

On Aug 31, 6:31 pm, Vadim Zeitlin <va...@wxwidgets.org> wrote:
> http://docs.wxwidgets.org/2.9.1/overview_unicode.html#overview_unicod...
>
>  Regards,
> VZ
>
> --
> TT-Solutions: wxWidgets consultancy and technical support
>                http://www.tt-solutions.com/
>
>  application_pgp-signature_part
> < 1KViewDownload

Vadim Zeitlin

unread,
Sep 1, 2010, 5:44:29 AM9/1/10
to wx-u...@googlegroups.com
On Tue, 31 Aug 2010 21:10:13 -0700 (PDT) neil <burd...@yahoo.co.uk> wrote:

n> Note: I initially tried to build wxWidgets 2.9.1 using wx_vc9.sln, but
n> found that the build order was wrong so had to run the build several
n> times to get everything to build. I aslo tried using wx_dll.dsw which
n> proved successful immediately so I assume the build order is correct
n> here.

Yes, this is a known problem (which unfortunately is not that easy to
solve).

n> However, when linking against my application code the libraries tried
n> to look in ~/lib/vc_amd64_dll, but wxWidgets had created a directory
n> named vc_dll. So to solve the issue I just renamed the directory. Are
n> you aware of this issue?

Do you use auto linking (i.e. include include/msvc/wx/setup.h) and really
building in 64 bits?

n> Or did I miss out a configuration step.

I think there is some mismatch between the way you built the library and
the way you use it although I have no idea how could linking succeed at all
if the libraries are 64 bit and the applications 32 (or vice versa).

n> Also the wx_dll.dsw didn't build the wxmsw29ud_ribbon.lib so had to
n> build it via the wx_vc9.sln as ribbon was not part of the wx_dll.dsw
n> solution. easy fixes just wondered if you had encountered them?

No but I'll add ribbon to wx_dll.dsw, thanks.

neil

unread,
Sep 1, 2010, 9:51:38 PM9/1/10
to wx-users
Hi
I managed to get my application running but it now crashes when I
try to load any images (worked under 32 bit 2.8.10 XP). I get a window
stating:

C:\MILXView-win32-depend\wxWidgets-2.9.1\include\wx/strvararg.h(449):
assert "(argtype & (wxFormatStringSpecifier<T>::value)) == argtype"
failed in wxArgNormalizer<unsigned __int64>::wxArgNormalizer(): format
specifier doesn't match argument type

The code in my application is unchanged i.e.

milxViewPageModel *model = new
milxViewPageModel(DEFAULT_PERSPECTIVE, &imageList);

// wxString is asigned "aal.hr" in the line below.
const wxString imageName = wxString::FromAscii(imageDataMap-
>GetString(IMAGE_KEY_IMAGE_NAME));

for( int i=0; i<DEFAULT_VIEW_COUNT; i++ )
{
model->SetView( i, DEFAULT_VIEWS[i], imageName );
}
milxViewPage *page = new milxViewPage( (wxWindow*)
milxViewController::GetInstance()-
>GetViewNotebook(), model);
AddPage(page, imageName);

void milxViewController::AddPage(milxViewPage * page, const wxString
&title)
{
pages.push_back(page);
page->GetModel()->selected_view_changed.connect(sigc::mem_fun(*this,
&milxViewController::OnViewSelectionChanged));
GetViewNotebook()->AddPage(page, title, true); // < -- Crashes on
this line
PageSelected(page);
}

where GetViewNotebook() returns a wxAuiNotebook. I'm building on
Visual Studio 9 2008, windows 7 64 bit machine.

Note: when I examine "imageName" in the VS debugger m_impl is
"aal.hdr" but m_convertedToChar has a m_str of 0x0000000000000000
<badPtr> and a m_len of 1475739528967641292.

Under 2.8.10 I don't have m_convertedToChar value, Is this because
setup.h has wxUSE_UNICODE = 0 here and wxUSE_UNICODE = 1 in 2.9.1 by
default?

In reply to your previous post...

> Do you use auto linking (i.e. include include/msvc/wx/setup.h) and really
> building in 64 bits?

Not sure what you mean by this. The steps I use to build wxWidgets
2.9.1 on visual Studio 9 2008 are;
1. Download and untar from wxWidgets website
2. Load C:\MILXView-win32-depend\wxWidgets-2.9.1\build\msw\wx_dll.dsw
3. Go into the configuration manager and change "Active platform
solution" to X64 (copy settings from WIN32)
4. Build Solution for "DLL Debug" and "DLL Release"

Thanks a lot for your help, it's much appreciated

Neil

On Sep 1, 7:44 pm, Vadim Zeitlin <va...@wxwidgets.org> wrote:
>  application_pgp-signature_part
> < 1KViewDownload

Vadim Zeitlin

unread,
Sep 2, 2010, 4:39:07 AM9/2/10
to wx-u...@googlegroups.com
On Wed, 1 Sep 2010 18:51:38 -0700 (PDT) neil <burd...@yahoo.co.uk> wrote:

n> I managed to get my application running but it now crashes when I
n> try to load any images (worked under 32 bit 2.8.10 XP). I get a window
n> stating:
n>
n> C:\MILXView-win32-depend\wxWidgets-2.9.1\include\wx/strvararg.h(449):
n> assert "(argtype & (wxFormatStringSpecifier<T>::value)) == argtype"
n> failed in wxArgNormalizer<unsigned __int64>::wxArgNormalizer(): format
n> specifier doesn't match argument type

This is not a crash but an assert failure (the difference being that the
latter can be ignored and doesn't arise in release builds) but it still
needs to be fixed, of course.

n> GetViewNotebook()->AddPage(page, title, true); // < -- Crashes on this line

Could you please look at the stack after this call? You should see a call
to wxString::Printf() or Format() somewhere in it, can you please tell me
where is it exactly?

n> Under 2.8.10 I don't have m_convertedToChar value, Is this because
n> setup.h has wxUSE_UNICODE = 0 here and wxUSE_UNICODE = 1 in 2.9.1 by
n> default?

Roughly speaking yes. But you shouldn't care about wxString internals
anyhow (except m_impl for debugging purposes maybe). IOW it's normal for
m_str to be NULL and m_len to be -1.

n> > Do you use auto linking (i.e. include include/msvc/wx/setup.h) and really
n> > building in 64 bits?
n>
n> Not sure what you mean by this. The steps I use to build wxWidgets
n> 2.9.1 on visual Studio 9 2008 are;
n> 1. Download and untar from wxWidgets website
n> 2. Load C:\MILXView-win32-depend\wxWidgets-2.9.1\build\msw\wx_dll.dsw
n> 3. Go into the configuration manager and change "Active platform
n> solution" to X64 (copy settings from WIN32)
n> 4. Build Solution for "DLL Debug" and "DLL Release"

Well, the past about manually changing platform to x64 was unknown to me
which was why I couldn't understand how were you getting the x64 build.

neil

unread,
Sep 2, 2010, 8:23:03 PM9/2/10
to wx-users
> Could you please look at the stack after this call? You should see a call
> to wxString::Printf() or Format() somewhere in it, can you please tell me
> where is it exactly?

It's a printf (see below)

wxbase291ud_vc_custom.dll!wxTrap() Line 1016 C++
wxbase291ud_vc_custom.dll!DoShowAssertDialog(const wxString &
msg={...}) Line 1186 C++
wxbase291ud_vc_custom.dll!wxAppTraitsBase::ShowAssertDialog(const
wxString & msgOriginal={...}) Line 883 + 0x3c bytes C++
wxmsw291ud_core_vc_custom.dll!
wxGUIAppTraitsBase::ShowAssertDialog(const wxString & msg={...}) Line
502 C++
wxbase291ud_vc_custom.dll!ShowAssertDialog(const wxString &
file={...}, int line=449, const wxString & func={...}, const wxString
& cond={...}, const wxString & msgUser={...}, wxAppTraits *
traits=0x0000000003b53a60) Line 1253 + 0x1b bytes C++
wxbase291ud_vc_custom.dll!wxAppConsoleBase::OnAssertFailure(const
wchar_t * file=0x0000000005cc1c20, int line=449, const wchar_t *
func=0x0000000005cc1b40, const wchar_t * cond=0x0000000005cc1a50,
const wchar_t * msg=0x0000000005cc1980) Line 758 + 0x8f bytes C++
wxbase291ud_vc_custom.dll!wxDefaultAssertHandler(const wxString &
file={...}, int line=449, const wxString & func={...}, const wxString
& cond={...}, const wxString & msg={...}) Line 1053 + 0x12f bytes C++
wxbase291ud_vc_custom.dll!wxOnAssert(const char *
file=0x0000000001f98990, int line=449, const char *
func=0x0000000001f98b08, const char * cond=0x0000000001f98a10, const
char * msg=0x0000000001f98a58) Line 1129 + 0x7e bytes C++
wxmsw291ud_aui_vc_custom.dll!wxArgNormalizer<unsigned
__int64>::wxArgNormalizer<unsigned __int64>(unsigned __int64
value=97250176, const wxFormatString * fmt=0x0000000000afe398,
unsigned int index=1) Line 449 + 0x65 bytes C++
wxmsw291ud_aui_vc_custom.dll!wxArgNormalizerWchar<unsigned
__int64>::wxArgNormalizerWchar<unsigned __int64>(unsigned __int64
value=97250176, const wxFormatString * fmt=0x0000000000afe398,
unsigned int index=1) Line 467 + 0x31 bytes C++
wxmsw291ud_aui_vc_custom.dll!wxString::Printf<unsigned
__int64,unsigned int,unsigned int,unsigned long>(const wxFormatString
& f1={...}, unsigned __int64 a1=97250176, unsigned int a2=1283469521,
unsigned int a3=268811, unsigned long a4=2) Line 2305 + 0xca bytes C+
+
wxmsw291ud_aui_vc_custom.dll!wxAuiManager::AddPane(wxWindow *
window=0x0000000005cbeb80, const wxAuiPaneInfo & pane_info={...})
Line 1014 + 0x72 bytes C++
wxmsw291ud_aui_vc_custom.dll!wxAuiNotebook::GetActiveTabCtrl() Line
3530 + 0x58 bytes C++
wxmsw291ud_aui_vc_custom.dll!wxAuiNotebook::InsertPage(unsigned
__int64 page_idx=0, wxWindow * page=0x0000000005e27950, const wxString
& caption={...}, bool select=true, const wxBitmap & bitmap={...})
Line 3124 + 0xd bytes C++
wxmsw291ud_aui_vc_custom.dll!wxAuiNotebook::AddPage(wxWindow *
page=0x0000000005e27950, const wxString & caption={...}, bool
select=true, const wxBitmap & bitmap={...}) Line 3090 C++
milx-lib.dll!milx::milxViewController::AddPage(milx::milxViewPage *
page=0x0000000005e27950, const wxString & title={...}) Line 346 C++
milx-lib.dll!
milx::milxViewController::AddPage(milx::milxImageDataMap *
imageDataMap=0x0000000005b7df50) Line 327 + 0x1a bytes C++

The code at this point is...

#ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN
// formatted input/output
// as sprintf(), returns the number of characters written or < 0
on error
// (take 'this' into account in attribute parameter count)
// int Printf(const wxString& format, ...);
WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxFormatString&),
DoPrintfWchar, DoPrintfUtf8)

Thanks
Neil

On Sep 2, 6:39 pm, Vadim Zeitlin <va...@wxwidgets.org> wrote:
>  application_pgp-signature_part
> < 1KViewDownload

Vadim Zeitlin

unread,
Sep 3, 2010, 7:13:08 AM9/3/10
to wx-u...@googlegroups.com
On Thu, 2 Sep 2010 17:23:03 -0700 (PDT) neil <burd...@yahoo.co.uk> wrote:

n> > Could you please look at the stack after this call? You should see a call
n> > to wxString::Printf() or Format() somewhere in it, can you please tell me
n> > where is it exactly?
n>
n> It's a printf (see below)

Thanks, I think this was fixed by r65054 which happened after 2.9.1. So
you should just update to the latest svn or apply the patch from
http://trac.wxwidgets.org/changeset/65054 to your local tree.

n> The code at this point is...
n>
n> #ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN
n> // formatted input/output
n> // as sprintf(), returns the number of characters written or < 0
n> on error
n> // (take 'this' into account in attribute parameter count)
n> // int Printf(const wxString& format, ...);
n> WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxFormatString&),
n> DoPrintfWchar, DoPrintfUtf8)

This code is actually fine, it's in the caller that there was a bug.

neil

unread,
Sep 7, 2010, 10:27:39 PM9/7/10
to wx-users
Thanks for your help.

I checked out from the SVN repository (r65473) and that stopped the
assert message box from appearing when loading these types of images.
However, a similar message appears now when I load DICOM images.

The stack dump is:

> wxbase292ud_vc_custom.dll!wxTrap() Line 1016 C++
wxbase292ud_vc_custom.dll!DoShowAssertDialog(const wxString &
msg={...}) Line 1186 C++
wxbase292ud_vc_custom.dll!wxAppTraitsBase::ShowAssertDialog(const
wxString & msgOriginal={...}) Line 883 + 0x39 bytes C++
wxmsw292ud_core_vc_custom.dll!
wxGUIAppTraitsBase::ShowAssertDialog(const wxString & msg={...}) Line
502 C++
wxbase292ud_vc_custom.dll!ShowAssertDialog(const wxString &
file={...}, int line=453, const wxString & func={...}, const wxString
& cond={...}, const wxString & msgUser={...}, wxAppTraits *
traits=0x0641cd88) Line 1253 + 0x11 bytes C++
wxbase292ud_vc_custom.dll!wxAppConsoleBase::OnAssertFailure(const
wchar_t * file=0x1934d788, int line=453, const wchar_t *
func=0x1934d6f8, const wchar_t * cond=0x1934d638, const wchar_t *
msg=0x1934d598) Line 758 + 0x74 bytes C++
wxbase292ud_vc_custom.dll!wxDefaultAssertHandler(const wxString &
file={...}, int line=453, const wxString & func={...}, const wxString
& cond={...}, const wxString & msg={...}) Line 1053 + 0xc2 bytes C++
wxbase292ud_vc_custom.dll!wxOnAssert(const char * file=0x0ed4b638,
int line=453, const char * func=0x0ed4b734, const char *
cond=0x0ed4b6b4, const char * msg=0x0ed4b6fc) Line 1129 + 0x69 bytes C
++
milx-TaskManagerPanelPlugin.dll!
wxArgNormalizer<float>::wxArgNormalizer<float>(float value=0.60661763,
const wxFormatString * fmt=0x00def844, unsigned int index=1) Line 453
+ 0x5a bytes C++
milx-TaskManagerPanelPlugin.dll!
wxArgNormalizerWchar<float>::wxArgNormalizerWchar<float>(float
value=0.60661763, const wxFormatString * fmt=0x00def844, unsigned int
index=1) Line 471 + 0x25 bytes C++
milx-TaskManagerPanelPlugin.dll!wxString::Printf<float>(const
wxFormatString & f1={...}, float a1=0.60661763) Line 2305 + 0x4b
bytes C++
milx-TaskManagerPanelPlugin.dll!
milx::milxTaskManagerPanel::UpdateDisplay() Line 260 + 0x44 bytes C++
milx-TaskManagerPanelPlugin.dll!
milx::milxTaskManagerPanel::OnTimer(wxTimerEvent & __formal={...})
Line 195 C++
wxbase292ud_vc_custom.dll!wxAppConsoleBase::HandleEvent(wxEvtHandler
* handler=0x064c1770, void (wxEvent &)* func=0x0ed124aa, wxEvent &
event={...}) Line 589 C++
wxbase292ud_vc_custom.dll!
wxAppConsoleBase::CallEventHandler(wxEvtHandler * handler=0x064c1770,
wxEventFunctor & functor={...}, wxEvent & event={...}) Line 601 C++

The line in my code which causes the assert is:

wxString buffer;

// Current Progress
buffer.Printf(wxT("%d"), info[i].GetProgress()); <--- Asserts
here.

The printf code looks like:

#ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN
// formatted input/output
// as sprintf(), returns the number of characters written or < 0
on error
// (take 'this' into account in attribute parameter count)
// int Printf(const wxString& format, ...);
WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxFormatString&),
DoPrintfWchar, DoPrintfUtf8)

Note: that I'm testing this on 32 bit windows machine. When I select
"Cancel" to supress the message the images load up ok.

Do you know of a fix for this?

Thanks again
Neil




On Sep 3, 9:13 pm, Vadim Zeitlin <va...@wxwidgets.org> wrote:
> On Thu, 2 Sep 2010 17:23:03 -0700 (PDT) neil <burde...@yahoo.co.uk> wrote:
>
> n> >  Could you please look at the stack after this call? You should see a call
> n> > to wxString::Printf() or Format() somewhere in it, can you please tell me
> n> > where is it exactly?
> n>
> n> It's a printf (see below)
>
>  Thanks, I think this was fixed by r65054 which happened after 2.9.1. So
> you should just update to the latest svn or apply the patch fromhttp://trac.wxwidgets.org/changeset/65054to your local tree.
>
> n> The code at this point is...
> n>
> n> #ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN
> n>   // formatted input/output
> n>     // as sprintf(), returns the number of characters written or < 0
> n> on error
> n>     // (take 'this' into account in attribute parameter count)
> n>   // int Printf(const wxString& format, ...);
> n>   WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxFormatString&),
> n>                         DoPrintfWchar, DoPrintfUtf8)
>
>  This code is actually fine, it's in the caller that there was a bug.
>
>  Regards,
> VZ
>
> --
> TT-Solutions: wxWidgets consultancy and technical support
>                http://www.tt-solutions.com/
>
>  application_pgp-signature_part
> < 1KViewDownload

Dimitri Schoolwerth

unread,
Sep 8, 2010, 2:31:52 AM9/8/10
to wx-users
On Wed, Sep 8, 2010 at 6:27 AM, neil <burd...@yahoo.co.uk> wrote:

> I checked out from the SVN repository (r65473) and that stopped the
> assert message box from appearing when loading these types of images.
> However, a similar message appears now when I load DICOM images.

[...]

> The line in my code which causes the assert is:
>
>      wxString buffer;
>
>      // Current Progress
>      buffer.Printf(wxT("%d"), info[i].GetProgress());   <--- Asserts
> here.
>

Does your GetProgress maybe return a 64-bit integer? You should either
convert/cast to an int, change the return type of GetProgress, or
change the format specifier (%d). The assert you were seeing earlier
on (and probably now) contained a hint about this: "format specifier
doesn't match argument type". I get the exact same assert with the
above code if I let the function return a float or 64-bit int.

Regards,
Dimitri

Reply all
Reply to author
Forward
0 new messages