"Hello, world!" tutorial available (Windows, mingw/msvc)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alf P. Steinbach

    "Hello, world!" tutorial available (Windows, mingw/msvc)

    Just because there seems to be a lack of post-standard _correct_
    tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.

    Disclaimer: written this evening so perhaps there are "bugs" in the
    presentation -- are there?

    Plea: if someone takes the time to convert the word document to clean
    xhtml perhaps with stylish clear readable layout, then it will be an
    incentive for me to go on to write a next part, and a next part...

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
  • Matthias Käppler

    #2
    Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)

    That's a good idea Alf.

    By the way:

    "As you become more experienced you will appreciate the comforts of an IDE
    (Integrated Development Environment) such as Visual Studio, or (free)
    DevC++ or (free) Eclipse, because then you know enough to make it do your
    bidding, but for now I recommend you stay with command line tools only so
    that you learn what goes on ?under the hood? and have full control."

    Exactly my thoughts (I can tell, because I did the same mistake and started
    off with a fully fledged IDE (VC++6), used it for like 3 years and was
    totally clueless when first using command line g++).

    One cosmetic thing: The exact name behind MinGW32 is "Minimalist GNU for
    Win32". But maybe I'm just nitpicking here :)

    Regards,
    Matthias

    Alf P. Steinbach wrote:
    [color=blue]
    > Just because there seems to be a lack of post-standard _correct_
    > tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.
    >
    > Disclaimer: written this evening so perhaps there are "bugs" in the
    > presentation -- are there?
    >
    > Plea: if someone takes the time to convert the word document to clean
    > xhtml perhaps with stylish clear readable layout, then it will be an
    > incentive for me to go on to write a next part, and a next part...
    >[/color]

    Comment

    • Stephan Brönnimann

      #3
      Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)

      Why restrict the tutorial to Windows?
      I'd suggest to provide for each program:
      + the explaine program itself
      + compilation under Windows
      + compilation under Unix

      Of course then there should be a section that deals with the
      installation of the complier and the development environment.

      If you don't insist on XHTML I'll convert your document to HTML
      (and later upgrade to XHTLM which I'm not familiar with :-)

      Regards,
      Stephan Brönnimann
      broeni@osb-systems.com

      Open source rating and billing engine for
      communication networks.

      Comment

      • Ioannis Vranos

        #4
        Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)

        Alf P. Steinbach wrote:
        [color=blue]
        > Just because there seems to be a lack of post-standard _correct_
        > tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.
        >
        > Disclaimer: written this evening so perhaps there are "bugs" in the
        > presentation -- are there?
        >
        > Plea: if someone takes the time to convert the word document to clean
        > xhtml perhaps with stylish clear readable layout, then it will be an
        > incentive for me to go on to write a next part, and a next part...[/color]



        #include <iostream> // std::cout
        #include <ostream> // std::endl

        int main()
        {
        std::cout << "Hello, world!" << std::endl;
        }



        <iostream> contains both cout and endl, so remove ostream from there.




        --
        Ioannis Vranos


        Comment

        • Ioannis Vranos

          #5
          Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)

          Alf P. Steinbach wrote:
          [color=blue]
          > Just because there seems to be a lack of post-standard _correct_
          > tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.
          >
          > Disclaimer: written this evening so perhaps there are "bugs" in the
          > presentation -- are there?
          >
          > Plea: if someone takes the time to convert the word document to clean
          > xhtml perhaps with stylish clear readable layout, then it will be an
          > incentive for me to go on to write a next part, and a next part...[/color]


          Also the tutorial is too long for a "hello world" program.




          --
          Ioannis Vranos


          Comment

          • Rob Williscroft

            #6
            Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)

            Ioannis Vranos wrote in news:1102776232 .29255@athnrd02 in comp.lang.c++:
            [color=blue]
            > Alf P. Steinbach wrote:
            >[color=green]
            >> Just because there seems to be a lack of post-standard _correct_
            >> tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.
            >>
            >> Disclaimer: written this evening so perhaps there are "bugs" in the
            >> presentation -- are there?
            >>
            >> Plea: if someone takes the time to convert the word document to clean
            >> xhtml perhaps with stylish clear readable layout, then it will be an
            >> incentive for me to go on to write a next part, and a next part...[/color]
            >
            >
            >
            > #include <iostream> // std::cout
            > #include <ostream> // std::endl
            >
            > int main()
            > {
            > std::cout << "Hello, world!" << std::endl;
            > }
            >
            >
            >
            > <iostream> contains both cout and endl, so remove ostream from there.
            >[/color]

            That isn't what my copy of the standard (27.3) says:

            Header <iostream> synopsis

            namespace std {
            extern istream cin;
            extern ostream cout;
            extern ostream cerr;
            extern ostream clog;
            extern wistream wcin;
            extern wostream wcout;
            extern wostream wcerr;
            extern wostream wclog;
            }

            But maybe I missed something, if so what ?

            Rob.
            --

            Comment

            • Razzer

              #7
              Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)

              >But maybe I missed something, if so what ?

              How could <iostream> define all these variables without the appropiate
              extra headers? I think that would violate the grammar rules.

              Comment

              • Rob Williscroft

                #8
                Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)

                Razzer wrote in news:1102791655 .067018.178540@ z14g2000cwz.goo glegroups.com
                in comp.lang.c++:
                [color=blue][color=green]
                >>But maybe I missed something, if so what ?[/color]
                >
                > How could <iostream> define all these variables without the appropiate
                > extra headers? I think that would violate the grammar rules.
                >
                >[/color]

                Its a Standard header it can do it by magic.

                IOW the Standard doesen't care how its done, just that it is done.

                Besides std::endl isn't a member of std::ostream so it isn't needed
                inorder to declare a usable std::cout object.

                In fact I don't realy see anything in the standard that would require
                std::cout to be usable (i.e. that std::ostream is a *complete* type)
                after only including <iostream>, since the only requirement seems to
                be that the objects are declared.

                27.3/1:

                The header <iostream> declares objects that associate objects
                with the standard C streams provided for by the functions declared
                in <cstdio> (27.8.2).

                Also note there are implementations in which std::endl *is not*
                available after only including <iostream>.

                Rob.
                --

                Comment

                • Mike Wahler

                  #9
                  Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)


                  "Ioannis Vranos" <ivr@remove.thi s.grad.com> wrote in message
                  news:1102776232 .29255@athnrd02 ...[color=blue]
                  > Alf P. Steinbach wrote:
                  >[color=green]
                  > > Just because there seems to be a lack of post-standard _correct_
                  > > tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.
                  > >
                  > > Disclaimer: written this evening so perhaps there are "bugs" in the
                  > > presentation -- are there?
                  > >
                  > > Plea: if someone takes the time to convert the word document to clean
                  > > xhtml perhaps with stylish clear readable layout, then it will be an
                  > > incentive for me to go on to write a next part, and a next part...[/color]
                  >
                  >
                  >
                  > #include <iostream> // std::cout
                  > #include <ostream> // std::endl
                  >
                  > int main()
                  > {
                  > std::cout << "Hello, world!" << std::endl;
                  > }
                  >
                  >
                  >
                  > <iostream> contains both cout and endl, so remove ostream from there.[/color]

                  <iostream> delcares 'cin' and 'cout' (and other objects).
                  The manipulator 'endl' is declared by <ostream>. While most
                  implementations I've seen will let you get away with using
                  'endl' without #including <ostream>, it's still technically
                  incorrect.

                  -Mike


                  Comment

                  • Razzer

                    #10
                    Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)

                    >Its a Standard header it can do it by magic.

                    I can certainly understand that, however...
                    [color=blue]
                    >Besides std::endl isn't a member of std::ostream so it isn't needed
                    >inorder to declare a usable std::cout object.[/color]

                    This is a better point.
                    [color=blue]
                    >In fact I don't realy see anything in the standard that would require
                    >std::cout to be usable (i.e. that std::ostream is a *complete* type)
                    >after only including <iostream>, since the only requirement seems to
                    >be that the objects are declared.[/color]

                    I think it is just of a reflection of how I read the Standard. I read
                    the synopsis of the <iostream> header file, and I see various
                    "extern"s. To me, this implies that a compiler needs to follow the
                    extern sematics, which would require a complete type.

                    Comment

                    • Alf P. Steinbach

                      #11
                      Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)

                      * Ioannis Vranos:[color=blue]
                      > Alf P. Steinbach wrote:
                      >[color=green]
                      > > Just because there seems to be a lack of post-standard _correct_
                      > > tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.
                      > >
                      > > Disclaimer: written this evening so perhaps there are "bugs" in the
                      > > presentation -- are there?
                      > >
                      > > Plea: if someone takes the time to convert the word document to clean
                      > > xhtml perhaps with stylish clear readable layout, then it will be an
                      > > incentive for me to go on to write a next part, and a next part...[/color]
                      >
                      >
                      > Also[/color]

                      ?

                      [color=blue]
                      > the tutorial is too long for a "hello world" program.[/color]

                      Well I think that might be the soundbite syndrome.

                      By now you've seen that even for the program text itself, which is
                      trivial and IMHO not the main point of "Hello, world", there was a new
                      thing to be learned for you (unfortunately also for many textbook authors).

                      What should I remove from the rest, do you think?

                      --
                      A: Because it messes up the order in which people normally read text.
                      Q: Why is it such a bad thing?
                      A: Top-posting.
                      Q: What is the most annoying thing on usenet and in e-mail?

                      Comment

                      • Alf P. Steinbach

                        #12
                        Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)

                        * Matthias =?ISO-8859-1?Q?K=E4ppler?= :[color=blue]
                        > [top-posting][/color]

                        Don't top post. See the FAQ. Corrected.


                        * Matthias =?ISO-8859-1?Q?K=E4ppler?= :[color=blue]
                        > * Alf P. Steinbach:
                        >[color=green]
                        > > Just because there seems to be a lack of post-standard _correct_
                        > > tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.[/color]
                        >
                        > That's a good idea Alf.[/color]

                        Apparently it was... ;-)

                        I did it because it's so often been the case that some ages-old
                        incorrect tutorial was to blame for questions here.

                        Latest now in the thread
                        «Beginnger: frustration right at the "Hello world" step!»...



                        [snip][color=blue]
                        > One cosmetic thing: The exact name behind MinGW32 is "Minimalist GNU for
                        > Win32". But maybe I'm just nitpicking here :)[/color]

                        Thanks. I've corrected that, and also some speling erors, and added
                        a link to the Windows compiled help format documentation of GNU tools
                        because the link to that from the mingw pages was broken. I just
                        replaced the earlier version.

                        --
                        A: Because it messes up the order in which people normally read text.
                        Q: Why is it such a bad thing?
                        A: Top-posting.
                        Q: What is the most annoying thing on usenet and in e-mail?

                        Comment

                        • Alf P. Steinbach

                          #13
                          Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)

                          * =?iso-8859-1?q?Stephan_Br= F6nnimann?=:[color=blue]
                          >
                          > Why restrict the tutorial to Windows?[/color]

                          You have a point. I think Mac people could benefit from a corresponding
                          tutorial for the Mac. On the other hand, if someone is running Linux,
                          then I think chances are that such a tutorial isn't needed (even though
                          both OS/X and Linux are *nix the kind of user and how it's used is very
                          different).

                          The reason I write for Windows is that that's what I'm best at.

                          The reason I think system-specific details are important in learning how
                          to use the tools is that there are no system-independent tools -- the
                          main hurdles are system-specific. The reason I think system-specific
                          details are important in learning how to use C++ (I've not come to that
                          yet...) is that doing system-specific things is a main reason for using
                          C++, and what C++ is traditionally used for. Otherwise one could just
                          as well use e.g. Java. For example, "The UNIX Programming Environment",
                          by Kernighan and Pike, was a great book to learn what C was all about.
                          Placing the language and its practical application in context -- what
                          to use it for, and what not.

                          [color=blue]
                          > I'd suggest to provide for each program:
                          > + the explaine program itself
                          > + compilation under Windows
                          > + compilation under Unix[/color]

                          I think compilation under Unix is pretty well covered by showing how
                          it's done using g++?

                          [color=blue]
                          > Of course then there should be a section that deals with the
                          > installation of the complier and the development environment.[/color]

                          Is there any *nix, with the possible exception of Max OS/X, that doesn't
                          have a C++ compiler installed?

                          [color=blue]
                          > If you don't insist on XHTML I'll convert your document to HTML
                          > (and later upgrade to XHTLM which I'm not familiar with :-)[/color]

                          Thanks, that would be great. XHTML is just a very well-defined and
                          somewhat restricted form of HTML. The reasons I think XHTML could be
                          better for this are that (1) HTML often becomes very browser-specific,
                          and (2) XHTML is probably _much_ better suited for further conversion,
                          and (3) XHTML is the current HTML standard: the old HTML is
                          yestercentury's technology... ;-)

                          --
                          A: Because it messes up the order in which people normally read text.
                          Q: Why is it such a bad thing?
                          A: Top-posting.
                          Q: What is the most annoying thing on usenet and in e-mail?

                          Comment

                          • Ioannis Vranos

                            #14
                            Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)

                            Alf P. Steinbach wrote:
                            [color=blue]
                            > Is there any *nix, with the possible exception of Max OS/X, that doesn't
                            > have a C++ compiler installed?[/color]


                            I do not think Mac OS X has not a C++ compiler. In a local COMDEX 2-3
                            years ago, I came across some Mac laptops with OS X at a Macintosh
                            booth, and checked it. I opened a console window and if i recall well it
                            had both gcc and g++.



                            --
                            Ioannis Vranos


                            Comment

                            • Chris Theis

                              #15
                              Re: &quot;Hello, world!&quot; tutorial available (Windows, mingw/msvc)


                              "Alf P. Steinbach" <alfps@start.no > wrote in message
                              news:41bb6e6f.3 2982656@news.in dividual.net...
                              [SNIP][color=blue]
                              >[color=green]
                              > > the tutorial is too long for a "hello world" program.[/color]
                              >
                              > Well I think that might be the soundbite syndrome.
                              >
                              > By now you've seen that even for the program text itself, which is
                              > trivial and IMHO not the main point of "Hello, world", there was a new
                              > thing to be learned for you (unfortunately also for many textbook[/color]
                              authors).[color=blue]
                              >
                              > What should I remove from the rest, do you think?
                              >[/color]

                              Well, this might be nit-picking but I´d put in the return statement in the
                              main function. We all know that it can be omitted for main() but IMHO a
                              newbie might be mislead. In the text it says that the default return value
                              is zero and that main returns an int. But due to the missing statement
                              people might think that this is the default behavior for all functions
                              and/or that the infamous void main(), which is seen way too often, is also
                              okay.

                              Cheers
                              Chris


                              Comment

                              Working...