Convert VB code to C code.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sebastian Kaliszewski

    #16
    Re: Convert VB code to C code.

    Richard Bos wrote:
    [color=blue]
    > John Smith <JSmith@mail.ne t> wrote:
    >
    >[color=green]
    >>Essentially , strings in C are arrays of characters, terminated with a
    >>NULL character.[/color]
    >
    >
    > _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'.[/color]

    Well, according to standard NULL should expand to 0. (void*)0 is not
    conformant IMHO (some pre C89 compilers did so)

    rgds
    Sebastian

    Comment

    • Richard Bos

      #17
      Re: Convert VB code to C code.

      Sebastian Kaliszewski <sk@bez.spamu.z .pl> wrote:
      [color=blue]
      > Richard Bos wrote:
      >[color=green]
      > > John Smith <JSmith@mail.ne t> wrote:
      > >[color=darkred]
      > >>Essentially , strings in C are arrays of characters, terminated with a
      > >>NULL character.[/color]
      > >
      > > _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'.[/color]
      >
      > Well, according to standard NULL should expand to 0. (void*)0 is not
      > conformant IMHO[/color]

      Ahem. Neither your humble nor my arrogant opinion are worth what the cat
      dragged in; it is the Standard which defines C, not our opinion. And the
      Standard says:

      7.17#3:
      # 3 The macros are
      # NULL
      # which expands to an implementation-defined null pointer constant;

      6.3.2.3#3:
      # 3 An integer constant expression with the value 0, or such an
      # expression cast to type void *, is called a null pointer constant.

      0 is an integer constant expression with the valud 0; (void *)0 is such
      an expression cast to type void *; it is, therefore, a null pointer
      constant; and because of that, it is a valid expansion of NULL.
      [color=blue]
      > (some pre C89 compilers did so)[/color]

      There was no such thing as void, pre-C89. IIRC the Standard Committee
      nicked it from C++.

      Richard

      Comment

      • pete

        #18
        Re: Convert VB code to C code.

        Sebastian Kaliszewski wrote:
        [color=blue]
        > Well, according to standard NULL should expand to 0. (void*)0 is not
        > conformant IMHO (some pre C89 compilers did so)[/color]

        What standard would that be?

        N869
        7.17 Common definitions <stddef.h>
        [#3] The macros are
        NULL
        which expands to an implementation-defined null pointer
        constant;
        6.3.2.3 Pointers
        [#3] An integer constant expression with the value 0, or
        such an expression cast to type void *, is called a null
        pointer constant.



        C89 last public draft
        4.1.5 Common definitions <stddef.h>
        The macros are
        NULL
        which expands to an implementation-defined null pointer constant;
        3.2.2.3 Pointers
        An integral constant expression with the value 0, or such an
        expression cast to type void * , is called a null pointer constant.

        --
        pete

        Comment

        • dandelion

          #19
          Re: Convert VB code to C code.


          "Richard Bos" <rlb@hoekstra-uitgeverij.nl> wrote in message
          news:4190df39.1 08259609@news.i ndividual.net.. .
          [color=blue]
          > There was no such thing as void, pre-C89. IIRC the Standard Committee
          > nicked it from C++.[/color]

          You don't.

          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.

          See
          A summary of the changes to the C programming language introduced with the ANSI C Standard.


          So much for Mr Professional... Don't you wish you had studied at the RUG?


          Comment

          • pete

            #20
            Re: Convert VB code to C code.

            dandelion wrote:
            [color=blue]
            > That was in '89. C++ was nowhere in sight. Yet.[/color]

            I'm seeing C++ from 1983.




            --
            pete

            Comment

            • Chris Torek

              #21
              Re: Convert VB code to C code.

              >"Richard Bos" <rlb@hoekstra-uitgeverij.nl> wrote in message[color=blue]
              >news:4190df39. 108259609@news. individual.net. ..[color=green]
              >> There was no such thing as void, pre-C89. IIRC the Standard Committee
              >> nicked it from C++.[/color][/color]

              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.

              In article <news:4190e3e5$ 0$9264$e4fe514c @dreader10.news .xs4all.nl>
              dandelion <dandelion@mead ow.net> wrote:[color=blue]
              >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.[/color]

              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++.
              --
              In-Real-Life: Chris Torek, Wind River Systems
              Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
              email: forget about it http://web.torek.net/torek/index.html
              Reading email is like searching for food in the garbage, thanks to spammers.

              Comment

              • Dan Pop

                #22
                Re: Convert VB code to C code.

                In <cmqsmd015ut@ne ws4.newsguy.com > Chris Torek <nospam@torek.n et> writes:
                [color=blue][color=green]
                >>"Richard Bos" <rlb@hoekstra-uitgeverij.nl> wrote in message
                >>news:4190df39 .108259609@news .individual.net ...[color=darkred]
                >>> There was no such thing as void, pre-C89. IIRC the Standard Committee
                >>> nicked it from C++.[/color][/color]
                >
                >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.[/color]

                "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
                --
                Dan Pop
                DESY Zeuthen, RZ group
                Email: Dan.Pop@ifh.de
                Currently looking for a job in the European Union

                Comment

                • ozbear

                  #23
                  Re: Convert VB code to C code.

                  On Tue, 09 Nov 2004 13:54:54 GMT, rlb@hoekstra-uitgeverij.nl (Richard
                  Bos) wrote:
                  [color=blue]
                  >John Smith <JSmith@mail.ne t> wrote:
                  >[color=green]
                  >> Essentially, strings in C are arrays of characters, terminated with a
                  >> NULL character.[/color]
                  >
                  >_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[/color]

                  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
                  --
                  A: Because it fouls the order in which people normally read text.
                  Q: Why is top-posting such a bad thing?
                  A: Top-posting.
                  Q: What is the most annoying thing on usenet and in e-mail?

                  Comment

                  • Frank Adam

                    #24
                    Re: Convert VB code to C code.

                    On Tue, 09 Nov 2004 14:27:57 GMT, pete <pfiland@mindsp ring.com> wrote:
                    [color=blue]
                    >Richard Bos wrote:[color=green]
                    >>
                    >> John Smith <JSmith@mail.ne t> wrote:
                    >>[color=darkred]
                    >> > Essentially, strings in C are arrays of characters,
                    >> > terminated with a
                    >> > NULL character.[/color]
                    >>
                    >> _Null_ character, please. Case is important.[/color]
                    >
                    >or "null character",
                    >since it's not at the begining ofasentence.
                    >[color=green]
                    >> NULL is a macro expanding
                    >> to a null pointer constant, not a character.[/color]
                    >
                    >... and a null pointer is a pointer
                    >that compares equal to a null pointer constant.
                    >[/color]
                    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. ;-)

                    --

                    Regards, Frank

                    Comment

                    Working...