AnsweredAssumed Answered

Selective compile in C

Question asked by bigmac on Feb 14, 2012
Latest reply on Feb 23, 2012 by sebasira

Hello all,

 

I am using CW6.3 for HCS08 devices.

 

My project uses a generalised array of function pointers -

 

// Table of user function pointers for each timeslot:
static const void (*Usr_func[])(void) = {
   Usr0_tic4,  Usr1_tic4, Usr0_tic8, Usr1_tic8,
   Usr0_tic16, Usr1_tic16, Usr2_tic16, Usr3_tic16 };

 

However, a specific version of the project may not make use of all of the functions. For each unused function, I would like to be able to automatically incorporate an empty function as a default, e.g.

void Usr0_tic4( void) { }

 

However, I have not been able to find a suitable #ifndef that achieves the desired result.  Within the primary project file, I would like to restrict the code to only those functions that are used, if at all possible.  The separate file containing the array would be standardised, and not require to be altered for different projects.

 

This concept works well for assembly code, where selective assembly, based on a non-defined subroutine name, is feasible.  I would like to do as similar thing with the C coded version.  Perhaps someone can suggest a method.  Otherwise, I will need to incorporate all the functions within the primary project file, whether utilised or not (which is probably not the "end of the world").

 

Regards,

Mac

Outcomes