Convert VB code to C code.

  • Thread starter Kenneth Osenbroch
  • Start date
C

Chris Torek

No, the "void" type itself (but not "void *") appeared some time
around 1979 or so, about the same time as PWB-Unix and Steve
Johnson's Portable C Compiler. ("void" and "enum" appeared about
the same time. PCC also introduced separated struct/enum namespaces
-- you could now write:

struct A { int a; int b; };
struct B { int b; int a; };

which in Dennis Ritchie's older compilers was invalid; all "struct"
members were in a single namespace, so each had to have a unique
name. This is at least part of the reason that Unix-y "struct"s
use per-struct member prefixes, e.g., "tm_year" inside a "struct
tm", or "st_dev" inside a "struct stat" -- not just "year" and
"dev". PCC had a backwards-compatiblility hack: if X was any
lvalue, or P was a pointer with structure type S, and you wrote
X.field or P->field, and "field" was not a member of the structure
S, PCC would search all the other "struct" and "union" types for
the first one with a member named "field", use that field's type
and offset, and emit a warning. Among other things, this meant
you could write:

struct { char lo, hi; };
short s;
...
s = some_expression();
printf("as word: %o; as bytes: %o, %o\n", s, s.lo, s.hi);

and the old "adb" program used this very construct. Yes, it
sign-extended the bytes, which I found quite annoying. Of course,
Dennis' original compilers did not have "unsigned char" either --
PCC added unsigned variants of all the integral types. Indeed,
early C had no "unsigned" keyword at all; if you wanted unsigned
integers, you declared pointers!)

The "void *" type was an ANSI-committee invention, though.

It was defined in the first ANSI-C (as opposed to old-style K&R) I used.
That was in '89. C++ was nowhere in sight. Yet.

This is not quite right either. The original ANSI C standard came
out in December 1989, yes, but Stroustrup's C++ book was out well
before that -- I believe I read it in 1986, and apparently it was
published in 1985. Of course, that particular C++ was a very
different language from today's C++.
 
D

Dan Pop

In said:
No, the "void" type itself (but not "void *") appeared some time
around 1979 or so, about the same time as PWB-Unix and Steve
Johnson's Portable C Compiler. ("void" and "enum" appeared about
the same time.

"enum" predates "void". It was introduced with the V7 compiler, together
with better support for structures (structures as function parameters and
as function return types, as well as simple assignment operands), slightly
after K&R1 went to print.

Dan
 
O

ozbear

_Null_ character, please. Case is important. NULL is a macro expanding
to a null pointer constant, not a character. (void *)0 is hardly a good
string terminator, let alone '(void *)0'.

Richard

That is one valid expansion. It is also allowed to expand to an
unadorned 0 which will give the correct result, but for the
wrong reason (i.e., luck) when depended upon.

Oz
 
F

Frank Adam

or "null character",
since it's not at the begining ofasentence.


... and a null pointer is a pointer
that compares equal to a null pointer constant.
How about a Null (pointer) and a Nul (character) ? :)

Jaysus, i remember you guys bickering on this many moons ago when i
frequented the C echos.... and you are still fighting over it ?

Just settle on 'zero' already. ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top