- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi together,
I'm using memcpy and get the warning from the title.
I already include string.h - what else can I do besides ignoring this error?
Best regards
Hannes Baumgart
Solved! Go to Solution.
- Labels:
-
Debug
-
SDK 2.X
-
WICED Sense
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
of course you shouldn't just ignore compiler warnings, but this can be ignored and the program will still run.
A better way is to insert this:
extern void *memcpy(void *dest, const void *src, size_t n);
Best regards
Hannes Baumgart
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note that not all standard C library functions are available because the ROM and RAM space on the chip is limited. I know other posts that the strn* functions are not available in the ROM and the SDK does not link in the missing std functions in because they will very easily overflow the available space.
I think this user addresses something similar to the issue you are seeing: Re: Initializing an array causes a "undefined reference to memset"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
You don' t need to add the string.h file. It is already included in Project Explore>Tools>ARM_GNU>include>string.h. The compiler should find it when you build and link the project.
I have used memcpy plenty of time in the Mpression Odyssey project without any compilation issues.
Just add #include <string.h> to your project and you should be good to go.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
of course you shouldn't just ignore compiler warnings, but this can be ignored and the program will still run.
A better way is to insert this:
extern void *memcpy(void *dest, const void *src, size_t n);
Best regards
Hannes Baumgart
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the help Hannes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I wrote a quick sample code with memcpy on SDK 2.2.1
I don't see the compilation error, I don't even define string.h
/*
* Copyright 2015, Broadcom Corporation
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
* the contents of this file may not be disclosed to third parties, copied
* or duplicated in any form, in whole or in part, without the prior
* written permission of Broadcom Corporation.
*/
/** @file
*
*
*/
#include "platform.h"
/******************************************************
* Function Prototypes
******************************************************/
void main_app(void);
/******************************************************
* Variables Definitions
******************************************************/
// Following structure defines UART configuration
const BLE_PROFILE_PUART_CFG puart_cfg =
{
/*.baudrate =*/ 115200,
/*.txpin =*/ PUARTDISABLE | GPIO_PIN_UART_TX,
/*.rxpin =*/ PUARTDISABLE | GPIO_PIN_UART_RX,
};
/******************************************************
* Function Definitions
******************************************************/
// Application initialization
APPLICATION_INIT()
{
//Call main
main_app();
}
void main_app(void)
{
unsigned char tab1[10];
unsigned char tab2[10];
memset(tab1, 0, 10);
memset(tab2, 0, 10);
tab2[0]= 1;
memcpy(tab1, tab2, 1);
return;
}