Path: utzoo!utgpu!news-server.csri.toronto.edu!torsqnt!lethe!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Newsgroups: comp.lang.c Subject: Re: Operations on pointers to void. Message-ID: <1990Aug16.014947.1999@druid.uucp> Date: 16 Aug 90 01:49:47 GMT References: <482@array.UUCP> <1990Aug12.231202.23826@druid.uucp> <174@srchtec.UUCP> Organization: D'Arcy Cain Consulting, West Hill, Ontario Lines: 29 In article <174@srchtec.UUCP> johnb@srchtec.UUCP (John Baldwin) writes: >In article <1990Aug12.231202.23826@druid.uucp> darcy@druid.uucp > (D'Arcy J.M. Cain) writes: >>know that the data can be any type but we want to treat it as bytes. Perhaps >>we need a new type which acts like void * but allows pointer arithmetic based >>on the smallest data type supported by the system, usually (but not always) >>a byte. > >There is a simple fix to this: you can operate on void pointers by casting >them to a useful type. For example, perhaps you are writing a function foo() I understand how to cast. All I am saying is that it shouldn't be necessary. I find casts to be clumsy and try to avoid them wherever I can. I think it is better to define your functions and data types so that any conversion is automatically done by the compiler. If the language supported pointer arithmetic on void * (or supplied another data type with the same features) this would be possible. Note that GNU C does support it and I can't see any harm in it. ANSI code that doesn't know about it runs just fine but if you use the feature you do no harm either. So can anyone suggest any reason why supporting this feature would break code or otherwise be a problem. Of course code which used this feature would be unportable but what other problems would this cause? -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | MS-DOS: The Andrew Dice Clay West Hill, Ontario, Canada | of operating systems. + 416 281 6094 |