CH_CFG_SYSTEM_HALT_HOOK compilation errors
-
- Posts: 36
- Joined: Tue Jan 13, 2015 6:33 am
- Has thanked: 8 times
CH_CFG_SYSTEM_HALT_HOOK compilation errors
GCC outputs a million errors when I try to add some logging code to the CH_CFG_SYSTEM_HALT_HOOK definition within chconf.h. I have a standalone logging header file that I #include at the top of chconf.h that includes board.h, stm32f4xx.h, a few standard lib headers, and a few definitions for reading/writing to the RTC backup registers. The errors are generally of the form "bad instruction" or "junk at end of line". Does the way chibios get compiled in the makefile prevent including any standard libraries within chconf.h? I feel like I must be doing something wrong since the hooks don't seem very useful if I can't have access to at least some super basic functions.
-
- Posts: 135
- Joined: Wed Feb 04, 2015 5:03 pm
- Location: CITEC, Bielefeld University, germany
- Has thanked: 15 times
- Been thanked: 24 times
- Contact:
Re: CH_CFG_SYSTEM_HALT_HOOK compilation errors
Hi,
I would recommend to put your code in an external function and just add the according call to the hook:
If you then define logHaltError() in another .c file, you omit all the messy things that can happen with macros and don't have to include your dependencies in chconf.h. Maybe that helps you to find the root of your issue, just give it a try
I would recommend to put your code in an external function and just add the according call to the hook:
Code: Select all
#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
_Pragma("GCC diagnostic ignored \"-Wimplicit-function-declaration\"" ) \
logHaltError(reason); \
_Pragma("GCC diagnostic pop") \
}
If you then define logHaltError() in another .c file, you omit all the messy things that can happen with macros and don't have to include your dependencies in chconf.h. Maybe that helps you to find the root of your issue, just give it a try
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: CH_CFG_SYSTEM_HALT_HOOK compilation errors
You may also put the function prototype in the hook before calling it, no need for pragmas.
Anyway, I agree that it is better to simply call a function from hooks, less risks (it is a macro surrounded by critical code).
Giovanni
Anyway, I agree that it is better to simply call a function from hooks, less risks (it is a macro surrounded by critical code).
Giovanni
Who is online
Users browsing this forum: No registered users and 4 guests