From: Ken Raeburn <raeburn@raeburn.org>
Cc: bug-guile@gnu.org
Subject: Re: MinGW port
Date: Mon, 11 Sep 2006 20:56:27 -0400 [thread overview]
Message-ID: <D640EA02-1D1A-4F74-AECF-842298BE6A2C@raeburn.org> (raw)
In-Reply-To: <4503047A.7080403@web.de>
On Sep 9, 2006, at 14:14, Nils Durner wrote:
> Hi,
>
> first of all, sorry for the late reply.
>
>>> - execv (exec_file, exec_argv);
>>> + execv (exec_file,
>>> +#ifdef __MINGW32__
>>> + (const char * const *)
>>> +#endif
>>> + exec_argv);
Is the execv declaration (in some header file) part of mingw, or
Windows?
The SUSv2 spec (http://opengroup.org/onlinepubs/007908799/xsh/
exec.html) and the POSIX.1 2004 spec (http://www.opengroup.org/
onlinepubs/000095399/functions/exec.html) say "char *const argv[]",
i.e., no "const" qualifier on the character data. So does the Mac OS
X man page I just pulled up, and the Linux (GNU libc) one. Sounds
like Windows/Mingw is the odd one out -- and, one could argue, wrong.
>>
>> Thanks for the patch, but do you understand exactly what the
>> Win32/MinGW compiler is complaining about?
> No, I don't.
> IMHO, gcc treats "const char *const *" wrong.
It treats it consistently with the ANSI C standard. A "char **"
value can't be assigned to a "const char * const *" lvalue without
explicit conversion. You can add qualifiers at the first level of
indirection only.
There's a weird broken case you can construct if you allow that, but
I forget the details. I think it was something like:
void function1 () {
char **stringarray = calloc(10, sizeof(char*));
function2 (stringarray); // invalid
stringarray[0][0] = 0;
}
void function2 (const char **ptr) {
static const char x[] = { /*...*/ };
ptr[0] = x;
}
Now, if you allow the call to function2 without casting, this code
would have no type errors but the assignment at the end of function1
would be writing into storage defined as const. (String literals
introduce some similar unfortunate lossage, when they're treated as
"char*" values, but that's a known issue, and not what's happening
here.)
The C++ rules are more complicated, and allow adding qualifiers at
different levels of indirection, but with other restrictions that
still prevent this sort of thing from happening.
>> I thought it was generally
>> OK to pass a non-const value to a function whose corresponding
>> parameter is declared as const.
> Right.
First level of indirection only. Same for "volatile".
>
> The sample code for execv() at
>
> http://msdn.microsoft.com/library/en-us/vccore98/HTML/_crt__execv.
> 2c_._wexecv.asp
> triggers the same warning with GCC.
> I have no access to a Visual C compiler ATM, but I doubt MS' sample
> code
> causes warnings with their compiler.
That's for a function "_execv". Is "execv" also defined by MS-
provided headers? By mingw? By Guile? If execv is defined as a
macro expanding to _execv, perhaps it should be casting its
argument's type.
Ken
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
next prev parent reply other threads:[~2006-09-12 0:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-22 16:42 MinGW port Nils Durner
2006-09-04 22:20 ` Neil Jerram
2006-09-04 23:11 ` Kevin Ryde
2006-09-06 1:23 ` Rob Browning
2006-09-09 18:14 ` Nils Durner
2006-09-12 0:56 ` Ken Raeburn [this message]
2006-09-14 0:21 ` Kevin Ryde
2006-09-25 17:54 ` Nils Durner
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
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D640EA02-1D1A-4F74-AECF-842298BE6A2C@raeburn.org \
--to=raeburn@raeburn.org \
--cc=bug-guile@gnu.org \
/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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).