dynarray Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

dynarray

Post by raananb »

An application which has been compiled with no errors since a number of years on MSW and OSX, now raises a problem with the code below.

Under Windows 10, with today's trunk and Visual Studio 2017 WX_DECLARE_OBJARRAY is undelined with green wigglies, reporting that the function declaration is not found but finally getting the application up and running.

Under OSX (10.13.5) GCC 8 raises an error in the second line, pointing at the beginning of the line and claiming a ')'. OSX then raises an error on the fourth line "out-of-line definition of 'Clone' does not match any declaration in wxOnjectArrayTraitsForArrayOfCFTextCtrlPointers'

#include <wx/dynarray.h>
WX_DECLARE_OBJARRAY(wxTextCtrl*, ArrayOfCFTextCtrlPointers);
#include <wx/arrimpl.cpp>
WX_DEFINE_OBJARRAY(ArrayOfCFTextCtrlPointers);

What is the problem here? (suggestions to use wxVector aside).
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: dynarray

Post by doublemax »

What exactly did change since the last time you compiled this? The compiler or the wxWidgets version, or both or anything else?

Code: Select all

WX_DECLARE_OBJARRAY(wxTextCtrl*, ArrayOfCFTextCtrlPointers);
This is a little strange, because WX_DECLARE_OBJARRAY assumes pointers anyway. So most likely it should be:

Code: Select all

WX_DECLARE_OBJARRAY(wxTextCtrl, ArrayOfCFTextCtrlPointers);
But then it shouldn't have worked before.
Use the source, Luke!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: dynarray

Post by PB »

There have been several changes to the obsolete containers code, see
https://github.com/wxWidgets/wxWidgets/ ... pe=Commits

I guess these should not break anything in the existing code (assuming the code was correct)...
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: dynarray

Post by raananb »

@doublemax
Both changed, apparently - the compiler with 10.13.5 and the code with the trunk.
I'll try with 3.1.1, and then look into wxVector...

@PB
I dont know if the code was correct, but it worked...
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: dynarray

Post by raananb »

No problems with 3.1.1

The trunk is no longer back-compatible for dynarray with 3.1.1 since June 1.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: dynarray

Post by PB »

raananb wrote:

Code: Select all

#include <wx/dynarray.h>
WX_DECLARE_OBJARRAY(wxTextCtrl*, ArrayOfCFTextCtrlPointers);
What is the problem here?
As doublemax already said, you are not to use a pointer to the class in the declaration of wxObjArray. The documentation states that, e.g. here, but I guess it could be a bit clearer about that...
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: dynarray

Post by raananb »

The compatibility break bug was reported and a patch was created to restore it (#18169).
Post Reply