c syntax passing const pointer to const data to function -


in function declaration below second argument const pointer const data.

ti_rc_t ti_uart_write_buffer(const ti_uart_t uart, const uint8_t *const data, uint32_t len); 

below example code calling function. why there (uint8_t *) before banner_str. usual syntax passing const pointer const data function? there other valid syntax?

#define banner_str ("hello, world!\n\n") ti_uart_write_buffer(ti_uart_0, (uint8_t *)banner_str, sizeof(banner_str)); 

thanks

the define banner_str array of characters type, in other words string. , therefore in function call need cast argument avoid compiler warnings valid way call function.

an other valid syntax instead of using define directive declare constant variable contains string write:

const char banner_str[] = "hello, world!\n\n"; ti_uart_write_buffer(ti_uart_0, (uint8_t *)banner_str, sizeof(banner_str)); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -