HI,
I want to get address of present instruction running, so I used this in my IAR(GCC Compiler)
void *addr = (void *) __builtin_extract_return_addr (__builtin_return_address (0));
but its giving me error
Error[Pe144]: a value of type "int" cannot be used to initialize an entity of type "void *"
Please support
Thanks
Hi @Shruthi_C
I tried that in S32 Design Studio and it works as expected. Not sure what's wrong in IAR.
Or you can use something like this:
#define __ASM __asm
#define __INLINE inline
#define __STATIC_INLINE static inline
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_LR(void)
{
register uint32_t result;
__ASM volatile ("MOV %0, LR\n" : "=r" (result) );
return(result);
}
And then:
uint32_t lr;
lr = __get_LR();
This also works on my side.
Regards,
Lukas
HI Lukas,
I tried the above content, but I am getting these warnings,
Warning[Pe172]: external/internal linkage conflict with previous declaration Hat line 85 of "internal preinclude.h"
Warning[Pe550]: variable "lr" was set but never used
Hi @Shruthi_C
what can you see on the line 85 in that file? I can't see such file in S32DS.
And the lr was obviously optimized out. I can see no problem with this.
Regards,
Lukas
Ok, what will happen if you try to use the same code without defines like this?
__attribute__( ( always_inline ) ) static inline uint32_t __get_LR(void)
{
register uint32_t result;
__asm volatile ("MOV %0, LR\n" : "=r" (result) );
return(result);
}
It looks like the syntax is different in IAR. Please ask IAR for help, it seems I can't help with this.
Regards,
Lukas