Using Not used variables

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

Using Not used variables

1,807 Views
BAN
Contributor II
Hi!
 
I'm using a lot of constant variables in a table and the code is written in a way that the linker cannot see that they are used and hence they will not be linked into the application. To avoid this I'm forced to do a dummy read for each variable.
 
Is there a way to tell the linker that the variables inside this segment must be linked even if they seem to be unused??
 
//Bengt
Labels (1)
0 Kudos
Reply
2 Replies

390 Views
stanish
NXP Employee
NXP Employee
Hi BAN,

This depends on CodeWarrior you are using. Could you specify which CodeWarrior you mean?

e.g. 8/16 bits CW: in linker parameter file (.prm) you can use:

ENTRIES   /* switch off smart linking to get unreferenced vector table */
 vectab                                                                            
END   
     

in other CW e.g. CW for MPC55xx  you can use  FORCEACTIVE keyword in the linker command file .lcf:

FORCEACTIVE { symbol1 symbol2 ... }


For more information I'd suggest you to see appropriate Build tools manual

Stanish
0 Kudos
Reply

390 Views
Lundin
Senior Contributor IV
In the .prm file, add each variable name below "ENTRIES":

ENTRIES
  x
END


/* C file */

#pragma CONST_SEG MY_CONST_DATA

int x my_table[N] = {...};

#pragma CONST_SEG DEFAULT

0 Kudos
Reply