Problem With Class

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem With Class

521 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Italia on Wed Jul 30 03:49:11 MST 2014
Hi,

i wrote this easy code in mt LPC2468 CPU:

/*
===============================================================================
Name        : $(Module).cpp
Author      : $(author)
Version     :
Copyright   : $(copyright)
Description : $(Module) definition
===============================================================================
*/

// TODO: insert include files here
//#include "RFIDREADER.cc"
// TODO: insert other definitions and declarations here

class My_Class
{
public:
My_Class(void);
unsigned int somma(unsigned int a, unsigned int b);
private:
unsigned int risultato;
};

My_Class::My_Class(void)
{
unsigned int i;
for(i=0;i<10;i++)
{
risultato=somma(i,i);
}
}
unsigned int My_Class::somma(unsigned int a, unsigned int b)
{
return (a+b);
}

My_Class first;

int main(void) {

// TODO: insert code here
//RFIDReader RF = new RFIDReader;
// force the counter to be placed into memory
volatile static int i = 0 ;

// Enter an infinite loop, just incrementing a counter
while(1)
i++;
return 0 ;
}

Now, when i put a breakpoint in the for cycle, the degugger never pass in
the cycle, so the object is not initialized. I wont to ask the reason and the possible solution. P.s i already try to define this class in the main loop and
in this case eserithing is well!
Labels (1)
0 Kudos
5 Replies

486 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Italia on Thu Jul 31 01:57:54 MST 2014
I found the same solution too! Thank u for your fast replay!!!
0 Kudos

486 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Thu Jul 31 01:22:42 MST 2014
There is a small error is the startup file.

Edit the startup file, and change
.weak   __libc_init_array
to
.global   __libc_init_array


This should fix the problem for you. We will put a fix into the Wizard for the next release of LPCXpresso
0 Kudos

486 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Italia on Thu Jul 31 00:58:09 MST 2014
Have someone give an eye to the code?
0 Kudos

486 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Italia on Wed Jul 30 07:28:35 MST 2014
I put a breakpoint in line 31, but debugger never stop in this place. that means that
the class is not costructed and initialized. I can access to the member but the costructor
is not invoked.

Instead if the class is defined in the main loop is costructed and everithing wirking perfectly.
Strange behavior. I tried to see in the init secion in startupfile but the __libc_init_array is
always 0.

0 Kudos

486 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Wed Jul 30 06:40:13 MST 2014
Your code works correctly here. Suggest you post your entire project so we can see exactly what you are trying to do.
See
http://www.lpcware.com/content/faq/lpcxpresso/how-importexport-projects
0 Kudos