Attachment:
crtend.c [1.04 KiB]
Downloaded 1731 times
FreeRTOS programmed by C language. If C++ code wants to add in FreeRTOS, you should update steps as following. C++ code can merge into Andes FreeRTOS.
1. Makefile :add define in Makefile :
Code:
C++ := $(CROSS_COMPILE)g++
add suffixes rules in Makefile:
Code:
%.o: %.cpp
$(TRACE_C++)
$(Q)$(C++) -c -MMD $(CFLAGS) -o $@ $<
2. add crtbegin.c/crtend.c files (attached files) into folder RTOSDemo_bsp and both file will be compiled into project.
3. call function "_crt_init"in Start.S:
Code:
! System reset handler
bal reset
bal _crt_init
! Infinite loop, if returned accidently
1:
b 1b
4. add code "void __cxa_atexit(void (*arg1)(void*), void* arg2, void* arg3)
{
}
void* __dso_handle = (void*) &__dso_handle;
" in startup-nds32.c:
Code:
#include "nds32_intrinsic.h"
#include "nds32_defs.h"
void __cxa_atexit(void (*arg1)(void*), void* arg2, void* arg3)
{
}
void* __dso_handle = (void*) &__dso_handle;
#ifndef VECTOR_BASE
#define VECTOR_BASE 0x00000000
Please pay attention to following:
C++ program can call C function but C program can't call C++
If you are curious above updates, you can check web site
https://gcc.gnu.org/onlinedocs/gccint/I ... ation.html to know reason.