Problems with IBM RS6000 C compiler

Larry Jones scjones at thor.UUCP
Tue Aug 7 00:27:07 AEST 1990


In article <1893 at tkou02.enet.dec.com>, diamond at tkou02.enet.dec.com (diamond at tkovoa) writes:
< In article <476 at mtndew.UUCP> friedl at mtndew.UUCP (Stephen J. Friedl) writes:
< >	extern int stat(char *filename, struct stat *stptr);
< >Shouldn't the "filename" argument be const qualified?
< 
< Suppose someone has a call of the form
<   x = stat("myfile", &my_stat);
< or
<   x = stat(my_mallocked_buffer_p, &my_stat);
< 
< stat is not defined by ANSI, so either way, it would not violate ANSI.
< But if const is included, it would break a lot of code that presently
< works under Unix(tm) operating system.  (I'm not sure what Posix(tm?)
< standards say.)  'Fraid I have to disagree with Karl Heuer's answer!

How would it break code?  It is perfectly valid to assign a pointer
to non-const to a pointer to const as shown in your examples.  It's
only the other direction (assigning a pointer to const to a pointer
to non-const) that requires a cast.

I agree with Steve -- filename should be const just like it is in
all of the stdio functions (according to ANSI).
----
Larry Jones                         UUCP: uunet!sdrc!thor!scjones
SDRC                                      scjones at thor.UUCP
2000 Eastman Dr.                    BIX:  ltl
Milford, OH  45150-2789             AT&T: (513) 576-2070
The living dead don't NEED to solve word problems. -- Calvin



More information about the Comp.lang.c mailing list