Ubuntu 18.04 wxArrayLong Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
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:

Ubuntu 18.04 wxArrayLong

Post by raananb »

I have

Code: Select all

wxArrayLong tiersReportMonthCredit[13];

for (int i = 0; i < 13; i++)
{
    tiersReportMonthCredit[i] = 0;
}
This compiles with no complaints in Windows (Visual Studio 2017) & OSX 10.13.5

It compiled with no problems in Ubuntu 16.04, but in Ubuntu 18.04 the compilation fails with the following messages:

error: no match for 'operator =' (operand types are 'wxArrayLong and 'long int')
*** WX_DEFINE_USER_EXPORTED_ARRAY_LONG(long,wxArrayLong, class WXDLLIMPEXP_BASE);
*** WX_DEFINE_USER_EXPORTED_ARRAY_LONG(long,wxArrayLong, class WXDLLIMPEXP_BASE);

Modifying the code as follows makes no difference.

Code: Select all

long z = 0;

for (int i = 0; i < 13; i++)
{
    tiersReportMonthCredit[i] = z;
}
What gives?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Ubuntu 18.04 wxArrayLong

Post by doublemax »

I'm surprised this compiles under Windows.

Code: Select all

wxArrayLong tiersReportMonthCredit[13];
This creates an array of 13 wxArrayLong, not an array of 13 longs.

Try this:

Code: Select all

wxArrayLong tiersReportMonthCredit;
tiersReportMonthCredit.Alloc(13);
BTW: It is recommended to use STL containers in user code, not these old wx containers.
Use the source, Luke!
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: Ubuntu 18.04 wxArrayLong

Post by raananb »

This creates an array of 13 wxArrayLong, not an array of 13 longs.
That was the idea... 13 arrays for the twelve months. Each item of each array holds a value for the [row,month]. A year total for each row is stored at month 0.

The solution to the problem is to replace the '= 0;' by 'Clear();' , i.e. tiersReportMonthCredit.Clear();

Using three different compilers has its positive side!

Thanks
Post Reply