cancel
Showing results for 
Search instead for 
Did you mean: 

Keil uvision create .lib file with parameters

tm3341
Associate II
Posted on January 10, 2016 at 01:12

Hello to all readers,

i'm really out of my mind here.

I searched but nothing positive.

What is my purpose here. I wanna make a .lib file (hidden code to user) but still allow to set some defines in compiler preprocessor which will be used in .lib file.

For example.

Lib file structure:

uint8_t myArray[ARRAY_SIZE];

I wanna have this #define ARRAY_SIZE to be able to set on user side, without recompile .c file again from which library was created.

Is this possible to set in keil and how?
2 REPLIES 2
Posted on January 10, 2016 at 04:01

Well you really can't pass preprocessor defines in that way. You either need to dynamically allocate structures, and pass by pointer and size, or you need to use symbols, where you define as externals in the library and populate in your application

In Lib

extern uint8_t *myArray;

extern uint32_t myArraySize;

In app

#define ARRAY_SIZE 1000

uint8_t myArray[ARRAY_SIZE];

uint32_t myArraySize = ARRAY_SIZE;

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tm3341
Associate II
Posted on January 10, 2016 at 09:07