Re: Scheme and libraries -- piggyback on Java?



On Tue, 12 Sep 2006 10:43:06 -0500, Matthias Blume
<find@xxxxxxxxxxxxxxxxxxxx> wrote:

George Neuner <gneuner2/@comcast.net> writes:

Some of the "enhanced K&R" compilers (circa 1977..1985) allowed void
pointers to be assigned to other pointer types without casting.
However, as of C89, casting void pointers has been required just as in
C++.

You are wrong about this:

http://david.tribble.com/text/cdiffs.htm

Whups! You are correct.

I suppose I did know at one time that void* was convertible without
casting, but I learned C during the transition period from K&R to
ANSI/ISO when it was normal to cast malloc() returns even if the
target was a char*. Ditto for parameters to, e.g., memcpy(), even if
the source was a char*. I also did a lot of embedded programming
using a number of differently extended compilers. I thus learned to
explicitly cast all conversions regardless of the theoretical need to
do so ... for code documentation if nothing else.

C89 tightened up many of the loose spots in K&R, and I did read the
spec on several occasions, but I suppose I unconsciously glossed over
the part about void* being compatible with other pointers without
casting.

I also just realized that I haven't used an actual C compiler since
about 1993. Since then, I have always compiled C code with a C++
compiler. With all warnings on, failure to cast to/from a void* gives
a portability warning. Since I would see the warning frequently when
dealing with C code, I guess it just reinforced my flawed
understanding.

Oh well. Live and learn.
George
--
for email reply remove "/" from address
.



Relevant Pages

  • Re: Garbage collection
    ... void fn{ ... void* const buf1 = malloc; ... If compiler can detect that 'fne' does not cache a pointer somewhere, it can possibly detect that 'buf1' goes out of scope at 'L2'. ... Some GC implementations that will actually scan the stack of all application threads for pointers into its managed heaps, and attempt to follow all the links to NULL. ...
    (comp.lang.c)
  • Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
    ... Best regards ... So now that I have gotten it to work in the VC++ compiler, ... mayby my compiler doesn't support pointers to pointers! ... from void* to other pointer types. ...
    (microsoft.public.vc.language)
  • Re: question
    ... > or the compiler will report an error. ... The remark about casting the return value of malloc ... (given that coercion of void * to ALMOSTANYTYPE * is automatic), ...
    (comp.lang.c)
  • Re: Is __int64 dead?
    ... Note also that while the compiler can implement native types efficiently, ... It makes very little sense to anyone on an architecture on which pointers ... Well, all pointers are convertible to void*, so make INT_PTR an integer ...
    (microsoft.public.vc.mfc)
  • Re: /DELAYLOAD Linux counterpart for shared objects
    ... A big disadvantage is that the compiler, ... pointers and makes sure the library is there). ... void, ... ub2 charset, ub2 ncharset); ...
    (comp.os.linux.development.apps)