Announcements
IMPORTANT: Cypress Developer Community is transitioning on October 20th. To learn more and be prepared for this change, check out our latest announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Smart Bluetooth

Anonymous
Not applicable

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

0 Likes
1 Solution
Anonymous
Not applicable

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

View solution in original post

6 Replies
MichaelF_56
Moderator
Moderator

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"

david_armour

0 Likes
MiTo_1583836
Contributor II

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.

0 Likes
Anonymous
Not applicable

hantron

You should be to ignore the warning because the function is there in the ROM.

-Kevin

0 Likes
Anonymous
Not applicable

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

View solution in original post

MichaelF_56
Moderator
Moderator

Thanks for the help Hannes.

0 Likes
MiTo_1583836
Contributor II

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;

}

0 Likes