I have a macro as follow.
#define WR_BLK_SIZE_REGINFO 123
Am using this macro in a library project(.a). Library projects are pre-compiled where the size of "WR_BLK_SIZE_REGINFO" cannot be changed as it is statically allocated in the library project.
Now how can I dynamically allocate preprocessor directives code?
I want something like below. Is that possible?
#define WR_BLK_SIZE_REGINFO malloc
Let me brief out more if confused.
- What for this macro is used?
Ans: This macro is used in various files of my library project. For reducing code complexity I am using a macro to fix a size
- Why do you want to malloc the macro?
Ans: Am doing a library project, where this library projects will be used in many controllers. Where each controller has its own memory set. So I can't fix the size of that macro statically. As it needs to be varied based on controllers memory.
Demonstrate some code?
Sample.h
#define WR_BLK_SIZE_REGINFO 123
sample.c
if( !((numItems >= 1) && (numItems <= WR_BLK_SIZE_REGINFO)) )
{
// logic
}
sample1.c
if( !((numItemsWrite >= 1) && (numItemsWrite <= WR_BLK_SIZE_REGINFO)) )
{
// logic
}
Note1: all the above files are library files which are pre-compiled and "123" is fixed here, which I don't want it to be fixed. I want to allocate dynamically.
Note2: Am not sure whether malloc is the right choice. All I need is I wanted to input "123" at run time in the library project or during compile time of application project(Input 123 from application project to library project)
Note3: Library project are built using MPLAB X IDE, basically it is a microchip project.