Hello,
I would like to know the difference between the 2 following versions of what I thought was the same piece of code.
// 1 ==================================================
// in the lib file
/*** BeginHeader table_matrice*/
extern const unsigned char table_matrice[];
/*** EndHeader */
const unsigned char table_matrice[]=
{
0xFE,0x01,
0x03,0x02,
0x0D,0x02,
0x31,0x02,
0xC1,0x02,
0x01,0x03,
0xFE,0x01
};
// accessed using : var = table_matrice[i];
// ====================================================
and the other version
// 2 ==================================================
// in main program, as global var
unsigned char* pt_table_matrice;
unsigned char* pt_table_matrice_h;
// in lib file
/*** BeginHeader init_matrice */
void init_matrice(void);
/*** EndHeader */
void init_matrice(void)
{
long mat1
mat1 = 14;
pt_table_matrice = xalloc(mat1*sizeof(char));
pt_table_matrice[ 0]= 0xFE ; pt_table_matrice[ 1]= 0x01 ;
pt_table_matrice[ 2]= 0x03 ; pt_table_matrice[ 3]= 0x02 ;
pt_table_matrice[ 4]= 0x0D ; pt_table_matrice[ 5]= 0x02 ;
pt_table_matrice[ 6]= 0x31 ; pt_table_matrice[ 7]= 0x02 ;
pt_table_matrice[ 8]= 0xC1 ; pt_table_matrice[ 9]= 0x02 ;
pt_table_matrice[ 10]= 0x01 ; pt_table_matrice[ 11]= 0x03 ;
pt_table_matrice[ 12]= 0xFE ; pt_table_matrice[ 13]= 0x01 ;
}
// accessed using : var = pt_table_matrice[i];
//====================================================
I imagine that it doesn’t, since it is no giving me the same result … but I can’t see the difference between the 2, except that the 2nd version stores the values in xmem, which is what I was looking for.
Anyone got any idea ?
Thanks