Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news1.tnib.de!feed.news.tnib.de!news.tnib.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Ian Collins <ian-news@hotmail.com> |
| Newsgroups | comp.lang.c |
| Subject | Re: Array sizes and const |
| Date | Mon, 04 Jun 2012 11:30:50 +1200 |
| Lines | 55 |
| Message-ID | <a32adaF5maU6@mid.individual.net> (permalink) |
| References | <jqdtou$koe$1@dont-email.me> <pan.2012.06.02.22.50.02.517000@nowhere.com> <jqedjj$9gi$1@dont-email.me> <39346056-1528-4667-85d2-a860b6ba018a@googlegroups.com> <a3221hF47cU9@mid.individual.net> <cd41e7a6-962b-43dc-997d-e4849482a33c@googlegroups.com> <a327a6F5maU3@mid.individual.net> <jqgpig$plu$1@dont-email.me> <a328b5F5maU4@mid.individual.net> <9aeb00b1-2fd5-4259-901b-54b6fbec8956@googlegroups.com> <a329evF5maU5@mid.individual.net> <jqgrmr$91a$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net +OBzjw3a4PRfZ2NN8GvQKQ6lCkePYX/GOojC0tnF9KfS4kfjY/KUlrkiT+w4VBE5Wx |
| Cancel-Lock | sha1:H95ra3mAJV/Bo5ht/dddJ9gg2gM= |
| User-Agent | Mozilla/5.0 (X11; SunOS i86pc; rv:12.0) Gecko/20120423 Thunderbird/12.0 |
| In-Reply-To | <jqgrmr$91a$1@dont-email.me> |
| Xref | csiph.com comp.lang.c:21782 |
Show key headers only | View raw
On 06/ 4/12 11:23 AM, BartC wrote:
> "Ian Collins"<ian-news@hotmail.com> wrote in message
> news:a329evF5maU5@mid.individual.net...
>> On 06/ 4/12 11:04 AM, Malcolm McLean wrote:
>>> בתאריך יום ראשון, 3 ביוני 2012 23:55:33 UTC+1, מאת Ian Collins:
>
>>> But if it sends the triangle to the rendering hardware directly, the
>>> ENGINE *
>>> is a const. If it buffers it, it is mutable.
>>
>> There's a good example of the confusion, does it modify the triangle or
>> not? From the description you give, it looks like if does not in either
>> case.
>>
>> It is very much the callers business to know whether the triangle it
>> passes will or will not be molested by the function. What if it has a
>> table of triangles in read only memory?
>>
>> The constness of the parameter has nothing to do with how the function
>> does its job.
>
> Would a const attribute be any use here:
Yes, change it and see:
void changestr(const char* s)
gcc x.c
x.c: In function ‘changestr’:
x.c:5:3: error: assignment of read-only location ‘*s’
> #include<stdio.h>
> #include<string.h>
>
> void changestr(char* s){
> s[0]='?';
> }
>
> int main(void)
> {
> changestr("abcdef");
> puts("abcdef");
> }
>
> I want to able to use changestr() to modify a string variable. But how can I
> stop a string literal being passed (which will either corrupt the literal,
> or will crash, on my tests)?
That's the "glorious mess" I mentioned up-thread.
C++ fixed this one, but I'm sure if the C committee tries, the fossils
would pop up and whine about breaking existing (already broken) code.
--
Ian Collins
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Array sizes and const Les Cargill <lcargill99@comcast.com> - 2012-06-02 15:43 -0500
Re: Array sizes and const Ian Collins <ian-news@hotmail.com> - 2012-06-03 08:56 +1200
Re: Array sizes and const Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-02 16:59 -0400
Re: Array sizes and const Les Cargill <lcargill99@comcast.com> - 2012-06-02 16:35 -0500
Re: Array sizes and const jgk@panix.com (Joe keane) - 2012-06-08 20:05 +0000
Re: Array sizes and const jgk@panix.com (Joe keane) - 2012-06-09 21:36 +0000
Re: Array sizes and const Les Cargill <lcargill99@comcast.com> - 2012-06-02 16:43 -0500
Re: Array sizes and const Keith Thompson <kst-u@mib.org> - 2012-06-02 14:59 -0700
Re: Array sizes and const Les Cargill <lcargill99@comcast.com> - 2012-06-02 17:12 -0500
Re: Array sizes and const Keith Thompson <kst-u@mib.org> - 2012-06-02 18:27 -0700
Re: Array sizes and const Les Cargill <lcargill99@comcast.com> - 2012-06-02 22:27 -0500
Re: Array sizes and const "BartC" <bc@freeuk.com> - 2012-06-03 11:24 +0100
Re: Array sizes and const Keith Thompson <kst-u@mib.org> - 2012-06-03 13:51 -0700
Re: Array sizes and const "BartC" <bc@freeuk.com> - 2012-06-04 12:20 +0100
Re: Array sizes and const Jens Gustedt <jens.gustedt@loria.fr> - 2012-06-04 13:54 +0200
Re: Array sizes and const Keith Thompson <kst-u@mib.org> - 2012-06-04 14:32 -0700
Re: Array sizes and const Nobody <nobody@nowhere.com> - 2012-06-02 23:50 +0100
Re: Array sizes and const Ian Collins <ian-news@hotmail.com> - 2012-06-03 10:53 +1200
Re: Array sizes and const Nobody <nobody@nowhere.com> - 2012-06-03 14:35 +0100
Re: Array sizes and const James Kuyper <jameskuyper@verizon.net> - 2012-06-02 21:11 -0400
Re: Array sizes and const Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-06-03 07:39 -0700
Re: Array sizes and const James Kuyper <jameskuyper@verizon.net> - 2012-06-03 16:03 -0400
Re: Array sizes and const Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-03 21:49 +0100
Re: Array sizes and const Keith Thompson <kst-u@mib.org> - 2012-06-03 14:49 -0700
Re: Array sizes and const Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-06-03 15:02 -0700
Re: Array sizes and const Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-04 01:21 +0100
Re: Array sizes and const Ian Collins <ian-news@hotmail.com> - 2012-06-04 09:08 +1200
Re: Array sizes and const Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-06-03 15:08 -0700
Re: Array sizes and const Ian Collins <ian-news@hotmail.com> - 2012-06-04 10:37 +1200
Re: Array sizes and const "BartC" <bc@freeuk.com> - 2012-06-03 23:47 +0100
Re: Array sizes and const Ian Collins <ian-news@hotmail.com> - 2012-06-04 10:55 +1200
Re: Array sizes and const Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-06-03 16:04 -0700
Re: Array sizes and const Ian Collins <ian-news@hotmail.com> - 2012-06-04 11:14 +1200
Re: Array sizes and const "BartC" <bc@freeuk.com> - 2012-06-04 00:23 +0100
Re: Array sizes and const Ian Collins <ian-news@hotmail.com> - 2012-06-04 11:30 +1200
Re: Array sizes and const "BartC" <bc@freeuk.com> - 2012-06-04 00:52 +0100
Re: Array sizes and const Ian Collins <ian-news@hotmail.com> - 2012-06-04 12:04 +1200
Re: Array sizes and const Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-04 01:39 +0100
Re: Array sizes and const Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-06-04 02:35 -0700
Re: Array sizes and const Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-04 01:33 +0100
Re: Array sizes and const Ian Collins <ian-news@hotmail.com> - 2012-06-04 12:35 +1200
Re: Array sizes and const pacman@kosh.dhis.org (Alan Curry) - 2012-06-04 21:28 +0000
Re: Array sizes and const James Kuyper <jameskuyper@verizon.net> - 2012-06-04 12:08 -0400
Re: Array sizes and const jgk@panix.com (Joe keane) - 2012-06-04 22:49 +0000
Re: Array sizes and const David Brown <david.brown@hesbynett.no> - 2012-06-03 15:46 -0500
Re: Array sizes and const Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-08 02:08 -0700
Re: Array sizes and const Les Cargill <lcargill99@comcast.com> - 2012-06-08 06:45 -0500
Re: Array sizes and const Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-08 10:49 -0700
Re: Array sizes and const Les Cargill <lcargill99@comcast.com> - 2012-06-08 18:05 -0500
Re: Array sizes and const Keith Thompson <kst-u@mib.org> - 2012-06-08 13:31 -0700
Re: Array sizes and const Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-08 20:30 -0700
csiph-web