Function alias for IDF [Resolved]
Posted: Fri Dec 04, 2020 10:24 pm
Hello,
I would like to make my own function names (aliases) for certain functions of the framework (including those of FreeRTOS). I mean, for example making a header file with alias definitions where I would do something like (myaliases.h):
And use it in my code like:
This ends up on build with the compilator message:
I have found this answer, but as I could read elsewhere, it's not a good idea to mess with the FreeRTOSConfig.h config file, which is reasonable. What's more, it would be just for FreeRTOS functions but I would like to make aliases for IDF in general.
How can I achieve that? Or should I configure the compiler somehow to stop treating this warning as error? And if so, how and would that be safe for the framework itself?
Thank you
Have a nice day
P.S. for the questions why the heck you want to do this is the answer "because I want"
P.P.S. I know I could wrap them inside inline functions, but I'm looking for a simple way (like shown above) which will alias only the function name
Stay safe!
I would like to make my own function names (aliases) for certain functions of the framework (including those of FreeRTOS). I mean, for example making a header file with alias definitions where I would do something like (myaliases.h):
Code: Untitled.c Select all
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "timer.h"
#define vTaskDelay MyTaskDelay // FreeRTOS function
#define timer_set_counter_value MyTimerSetCounterValue // IDF functionAnd use it in my code like:
Code: Untitled.c Select all
...
#include "myaliases.h"
void app_main() {
MyTaskDelay(1000);
MyTimerSetCounterValue(0, 0, 100);
}This ends up on build with the compilator message:
error: implicit declaration of function 'MyTaskDelay'; did you mean 'vTaskDelay'? [-Werror=implicit-function-declaration]
I have found this answer, but as I could read elsewhere, it's not a good idea to mess with the FreeRTOSConfig.h config file, which is reasonable. What's more, it would be just for FreeRTOS functions but I would like to make aliases for IDF in general.
How can I achieve that? Or should I configure the compiler somehow to stop treating this warning as error? And if so, how and would that be safe for the framework itself?
Thank you
Have a nice day
P.S. for the questions why the heck you want to do this is the answer "because I want"
P.P.S. I know I could wrap them inside inline functions, but I'm looking for a simple way (like shown above) which will alias only the function name
Stay safe!