mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Per Johansson <per@morth.org>
To: musl@lists.openwall.com
Subject: syslog.h prioritynames define not compatible with -Wwrite-strings
Date: Thu, 25 Aug 2016 09:47:06 +0200	[thread overview]
Message-ID: <CAOj2s=QtQW_BO3EF-cnYVXNMvXLDQ6zQ=iU_+dO9wr0Yu7QF1Q@mail.gmail.com> (raw)

Hello,

I'm trying to port a code base to musl. I've run into an issue with
prioritynames as defined by syslog.h:

CODE *pri_code = prioritynames;

produces

error: initialization discards 'const' qualifier from pointer target
type [-Werror=discarded-qualifiers]

This is repeated once per element in the array.

While the error message points to -Wdiscarded-qualifiers I believe
this is actually due to us using -Wwrite-strings which turns string
literals into type const char* instead of char*.

I suppose the most compatible solution would be to cast each string
literal to char* in the define. It's either that or use const char* in
the struct, but that's likely to cause issues in other programs.
Or use some trickery to disable the warning I suppose, wouldn't know about that.

Please CC me on any reply as I'm currently not subscribed.

Minimal code to reproduce:

#define SYSLOG_NAMES
#include <syslog.h>
CODE *c = prioritynames;

Compiles without warning:
gcc -nostdinc -isystem include -isystem obj/include -c test.c

Adding -Wwrite-strings give warnings:
gcc -Wwrite-strings -nostdinc -isystem include -isystem obj/include -c test.c

Regards,
-- 
Per Johansson


             reply	other threads:[~2016-08-25  7:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-25  7:47 Per Johansson [this message]
2016-08-30 21:20 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOj2s=QtQW_BO3EF-cnYVXNMvXLDQ6zQ=iU_+dO9wr0Yu7QF1Q@mail.gmail.com' \
    --to=per@morth.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).