Bug 4598 - const pointers in strtod/strtol
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Misc
Version: unspecified
Hardware: PC Linux
: P3 minor
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2010-04-18 08:36 EDT by Ben Millwood
Modified: 2011-02-04 11:09:19 EST
1 user (show)

See Also:


Attachments
const-compatibility with libc (4.79 KB, patch)
2010-04-18 08:36 EDT, Ben Millwood
also fix bug 4576 (4.91 KB, patch)
2010-04-18 08:43 EDT, Ben Millwood

Description Ben Millwood 2010-04-18 08:36:32 EDT
Created attachment 2335 [details]
const-compatibility with libc

This is pretty annoying and stupid. Any code that uses my strtol/strtod implementations will find that if they use a char ** for the second parameter then q3lcc will be upset because it wants a const char **. But then if they use a const char ** then gcc will complain while compiling the shared libraries because it wants a char **. The trouble is that the signatures given in bg_lib.h and in libc's stdlib.h differ in incompatible ways.
Turns out that the problem is you can't safely assign char ** to const char **:
http://c-faq.com/ansi/constmismatch.html
so a function accepting const char ** is inconvenient to use.
The only recourse is to cover the implementations in const-discarding casts which is unpleasant but seemingly necessary.
Comment 1 Ben Millwood 2010-04-18 08:43:30 EDT
Created attachment 2336 [details]
also fix bug 4576

The patch was incompatible with mine for 4576 so here is both of them together.
Comment 2 Thilo Schulz 2011-02-04 11:09:19 EST
Thanks, applied r1850