Converting memset to safememset Topic is solved

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
alwalker
Active Member
Posts: 45
Joined: Sun Apr 08, 2018 11:19 pm

Converting memset to safememset

Post by alwalker »

Hi,

I'm integrating a third party C code library into the XMOS environment and have encountered an issue with the string functions as specified in string.h.

I've followed the examples as best i can for using the safestring.h equivalents, but I'm still getting the below errors.

Can anyone advise on the correct syntax please?

The attachment shows the associated code fragments from a number of separate files for reference.

Kind regards,

Al


Combination 1

#define bzero(a, b) safememset(a, 0, b)
bzero((uint8_t *)message_info->payload.value8, message_info->payload_length_bytes);


Errors & Warnings
  • cannot pass unsafe pointer as safe pointer without explicit cast
  • incompatible type for argument 1 of `safememset'



Combination 2

#define bzero(a, b) _safe_memset((char * alias) a, 0, b)
bzero((uint8_t *)message_info->payload.value8, message_info->payload_length_bytes);


Errors & Warnings
  • expected ')'
  • implicit declaration of function '_safe_memset' is invalid in C99 [-Wimplicit-function-declaration]



Combination 3

No #define
safememset((uint8_t *)message_info->payload.value8, 0, message_info->payload_length_bytes);


Errors & Warnings
  • cannot pass unsafe pointer as safe pointer without explicit cast
  • incompatible type for argument 1 of `safememset'

Combination 4

No #define
_safe_memset((char * alias) message_info->payload.value8, 0, message_info->payload_length_bytes);


Errors & Warnings
  • expected ')'
  • implicit declaration of function '_safe_memset' is invalid in C99 [-Wimplicit-function-declaration]
200105 safememset error.png
(55.16 KiB) Not downloaded yet
200105 safememset error.png
(55.16 KiB) Not downloaded yet


View Solution
alwalker
Active Member
Posts: 45
Joined: Sun Apr 08, 2018 11:19 pm

Post by alwalker »

I solved the problem by creating my own (renamed) version of string.h using standard ANSI/C99 code and compiling as C rather than xC. The xTIMEcomposer version of string.h implements its ‘safe’ versions for use across taks, which I don’t need as all the C code is running in the same task.
Post Reply