AnsweredAssumed Answered

LPCOPEN compilation error

Question asked by Alvaro Lopes on Jul 18, 2017
Latest reply on Jul 19, 2017 by Alvaro Lopes

Good Morning!

 

I am migrating my project from CMSIS to LPCOPEN and I am having compilation problems with function "caddr_t _sbrk(int incr)". I am using LPC1768FBD100 chip.

 

Follow function:

 

#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>

 

 

caddr_t _sbrk(int incr)
{

extern char _pvHeapStart; /* Defined by the linker */
static char *heap_end;
char *prev_heap_end;
register char *stack_ptr __asm ("sp");

if (heap_end == 0)
{
heap_end = &_pvHeapStart;
}

prev_heap_end = heap_end;

if (heap_end + incr > stack_ptr)
{
errno = ENOMEM;

return (caddr_t)-1;
}

heap_end += incr;

return (caddr_t)prev_heap_end;

}

 

When I compile the project using CMSIS everything is ok,

 

Invoking: MCU C Compiler
arm-none-eabi-gcc -D__USE_CMSIS -D__CODE_RED -D__NEWLIB__ -I"../inc" -I"C:\Alvaro\thyssen\Workspace_alopes_MFG040029\depot\Drivers\LPC17xx\CMSIS_LPC17xx\inc" -I"C:\Alvaro\thyssen\Workspace_alopes_MFG040029\depot\Drivers\LPC17xx\Drivers_LPC17xx\inc" -O0 -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -mcpu=cortex-m3 -mthumb -D__NEWLIB__ -MMD -MP -MF"src/system.d" -MT"src/system.o" -MT"src/system.d" -o"src/system.o" "../src/system.c"
Finished building: ../src/system.c

 

but when I compile using lpcopen I have the follow compilation error:

 

Invoking: MCU C Compiler
arm-none-eabi-gcc -std=gnu99 -D__REDLIB__ -DDEBUG -D__CODE_RED -D__USE_LPCOPEN -D__LPC175X_6X__ -DUSB_HOST_ONLY -DCORE_M3 -I"C:\Alvaro\thyssen\Workspace_alopes_MFG040029\depot\Modulos\lpc_chip_175x_6x\inc" -I"C:\nxp\LPCXpresso_8.0.0_526\lpcxpresso\tools\lib\gcc\arm-none-eabi\4.9.3\include-fixed" -I"C:\nxp\LPCXpresso_8.0.0_526\lpcxpresso\tools\arm-none-eabi\include" -I"C:\nxp\LPCXpresso_8.0.0_526\lpcxpresso\tools\lib\gcc\arm-none-eabi\4.9.3\include" -I"C:\Alvaro\thyssen\Workspace_alopes_MFG040029\depot\Modulos\lpc_board_nxp_lpcxpresso_1769\inc" -I"C:\Alvaro\thyssen\Workspace_alopes_MFG040029\depot\Modulos\VOX5\VOX5\code\inc" -I"C:\Alvaro\thyssen\Workspace_alopes_MFG040029\depot\Modulos\VOX5\VOX5\lpcusblib\Drivers\USB" -I"C:\Alvaro\thyssen\Workspace_alopes_MFG040029\depot\Modulos\VOX5\VOX5\fatfs\inc" -O0 -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -mcpu=cortex-m3 -mthumb -specs=redlib.specs -MMD -MP -MF"code/src/main.d" -MT"code/src/main.o" -MT"code/src/main.d" -o "code/src/main.o" "../code/src/main.c"
../code/src/main.c:154:1: error: function '__errno' is initialized like a variable
int errno=0;
^
../code/src/main.c: In function '_sbrk':
../code/src/main.c:1080:8: error: 'errno' undeclared (first use in this function)
errno = ENOMEM;

In my file .c there is other functions that are using errno and not generate compilation erros.

 

Regards!

Outcomes