I am trying to use ARMCC Keil toolchain with CMake in vscode. I copied asm/compiler/linker flag from a working Keil project, except that I don't use .crf and .d files everywhere.
I have a strange behavior while being in debug with Cortex-debug extension in vscode. It compiles, links, but I noticed that when a function pointer is initialized at NULL, its value is evaluated at 0xffffffff.
To witness this more precisely (the application I am trying to build is quite big), I added code at the very beginning of main:
typedef void (*function_pointer)(void);
static function_pointer function = NULL;
/* ------------------------------------------------------------------- */
/**. * @brief Function for application main entry. */
int main(void) {
if(function != NULL)
{
function = (function_pointer)NULL;
function();
}
.
.
.
Debugger breaks within the if statement (so function is indeed not NULL while it should) After the NULL assignement, function is not assigned.
When I add a preprocess flag, I can be sure that NULL is expanded to 0 :
typedef void (*function_pointer)(void);
static function_pointer function = 0;
int main(void) {
if(function != 0)
{
function = (function_pointer)0;
function();
}
Note that I generate a .elf file with CMake but Keil generate a .axf file (which should be the same, as ELF files are standard).
I tried to generate.crf files and .d files but I am not sure they're needed with Cortex-debug vscode extension.
Also, I noticed that the programming behavior changes wether I program via Keil or via vscode. It takes much less time in vscode and the led on my debug board that blink sometimes with Keil doesn't light with vscode.
I can provide all details (CMake generation/compiler/linker commands, scatter file, debug launch command etc...). It is just that I wanted the question to be clear, and not provide 100+ lines of code, but feel free to ask anything
Thank you for your help