From 7c9726da64db1477e71c16b3a93353fd5826c41e Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sat, 18 Jul 2020 00:26:42 +0200 Subject: [PATCH] Fix -Wcast-qual compiler warning String literals have the type 'char[N]' by default. Allthough they are not really 'const', modifying a string literal is undefined behaviour. Therefore, to avoid mistakes, libdivecomputer uses the -Wwrite-strings compiler option to change the default type to 'const char[N]'. The cast that triggers the -Wcast-qual warning can be avoided by using a character array instead of string literal. --- examples/dctool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/dctool.c b/examples/dctool.c index ddcd596..3104bc4 100644 --- a/examples/dctool.c +++ b/examples/dctool.c @@ -240,7 +240,8 @@ main (int argc, char *argv[]) } // Translate the help option into a command. - char *argv_help[] = {(char *) "help", NULL, NULL}; + char helpcmd[] = "help"; + char *argv_help[] = {helpcmd, NULL, NULL}; if (help || argv[0] == NULL) { if (argv[0]) { argv_help[1] = argv[0];