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

Discussion in 'C++' started by Alf P. Steinbach, Dec 11, 2004.

  1. 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?
    Alf P. Steinbach, Dec 11, 2004
    #1
    1. Advertising

  2. 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:

    > 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...
    >
    Matthias =?ISO-8859-1?Q?K=E4ppler?=, Dec 11, 2004
    #2
    1. Advertising

  3. 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

    http://www.osb-systems.com
    Open source rating and billing engine for
    communication networks.
    =?iso-8859-1?q?Stephan_Br=F6nnimann?=, Dec 11, 2004
    #3
  4. Alf P. Steinbach wrote:

    > 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...




    #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

    http://www23.brinkster.com/noicys
    Ioannis Vranos, Dec 11, 2004
    #4
  5. Alf P. Steinbach wrote:

    > 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...



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




    --
    Ioannis Vranos

    http://www23.brinkster.com/noicys
    Ioannis Vranos, Dec 11, 2004
    #5
  6. Ioannis Vranos wrote in news:1102776232.29255@athnrd02 in comp.lang.c++:

    > Alf P. Steinbach wrote:
    >
    >> 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...

    >
    >
    >
    > #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.
    >


    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.
    --
    http://www.victim-prime.dsl.pipex.com/
    Rob Williscroft, Dec 11, 2004
    #6
  7. Alf P. Steinbach

    Razzer Guest

    >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.
    Razzer, Dec 11, 2004
    #7
  8. Razzer wrote in news:
    in comp.lang.c++:

    >>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.
    >
    >


    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::eek:stream 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::eek:stream 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.
    --
    http://www.victim-prime.dsl.pipex.com/
    Rob Williscroft, Dec 11, 2004
    #8
  9. Alf P. Steinbach

    Mike Wahler Guest

    "Ioannis Vranos" <> wrote in message
    news:1102776232.29255@athnrd02...
    > Alf P. Steinbach wrote:
    >
    > > 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...

    >
    >
    >
    > #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.


    <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
    Mike Wahler, Dec 11, 2004
    #9
  10. Alf P. Steinbach

    Razzer Guest

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

    I can certainly understand that, however...

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


    This is a better point.

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


    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.
    Razzer, Dec 11, 2004
    #10
  11. * Ioannis Vranos:
    > Alf P. Steinbach wrote:
    >
    > > 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...

    >
    >
    > Also


    ?


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


    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?
    Alf P. Steinbach, Dec 11, 2004
    #11
  12. * Matthias =?ISO-8859-1?Q?K=E4ppler?=:
    > [top-posting]


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


    * Matthias =?ISO-8859-1?Q?K=E4ppler?=:
    > * Alf P. Steinbach:
    >
    > > Just because there seems to be a lack of post-standard _correct_
    > > tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.

    >
    > That's a good idea Alf.


    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]
    > One cosmetic thing: The exact name behind MinGW32 is "Minimalist GNU for
    > Win32". But maybe I'm just nitpicking here :)


    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?
    Alf P. Steinbach, Dec 12, 2004
    #12
  13. * =?iso-8859-1?q?Stephan_Br=F6nnimann?=:
    >
    > Why restrict the tutorial to Windows?


    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.


    > I'd suggest to provide for each program:
    > + the explaine program itself
    > + compilation under Windows
    > + compilation under Unix


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


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


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


    > 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 :)


    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?
    Alf P. Steinbach, Dec 12, 2004
    #13
  14. Alf P. Steinbach wrote:

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



    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

    http://www23.brinkster.com/noicys
    Ioannis Vranos, Dec 12, 2004
    #14
  15. Alf P. Steinbach

    Chris Theis Guest

    "Alf P. Steinbach" <> wrote in message
    news:...
    [SNIP]
    >
    > > the tutorial is too long for a "hello world" program.

    >
    > 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?
    >


    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
    Chris Theis, Dec 12, 2004
    #15
  16. Alf P. Steinbach wrote:

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


    Actually, I think quite a lot, on a fresh installation at least :)
    C++ is actually not very common in the Linux/Unix camp. Almost *everything*
    is written in C, because C was the original implementation language of
    Unix. I think both were developed at the same time, maybe it's some sort of
    "traditional" thing.

    However, since the installation procedure of packages may completely differ
    from one Unix to others, I don't think it's necessary to describe how to
    install g++. The reader should know his system well enough to know how to
    install packages.
    Matthias =?ISO-8859-1?Q?K=E4ppler?=, Dec 12, 2004
    #16
  17. Alf P. Steinbach

    Greg Comeau Guest

    In article <cph4ng$flh$01$-online.com>,
    Matthias =?ISO-8859-1?Q?K=E4ppler?= <> wrote:
    >Alf P. Steinbach wrote:
    >> Is there any *nix, with the possible exception of Max OS/X, that doesn't
    >> have a C++ compiler installed?

    >
    >Actually, I think quite a lot, on a fresh installation at least :)


    Same for C then.... you're right, it's up to the vendor.

    >C++ is actually not very common in the Linux/Unix camp. Almost *everything*
    >is written in C, because C was the original implementation language of
    >Unix. I think both were developed at the same time, maybe it's some sort of
    >"traditional" thing.


    Some 15 or more years seperate the general public releases of the 2.
    --
    Greg Comeau / Comeau C++ 4.3.3, for C++03 core language support
    Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
    World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
    Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
    Greg Comeau, Dec 12, 2004
    #17
  18. Greg Comeau wrote:

    > Some 15 or more years seperate the general public releases of the 2.


    C and Unix? ^^
    Matthias =?ISO-8859-1?Q?K=E4ppler?=, Dec 12, 2004
    #18
  19. Alf P. Steinbach

    Greg Comeau Guest

    In article <cpi57b$6oa$01$-online.com>,
    Matthias =?ISO-8859-1?Q?K=E4ppler?= <> wrote:
    >Greg Comeau wrote:
    >
    >> Some 15 or more years seperate the general public releases of the 2.

    >
    >C and Unix? ^^


    Sorry, I meant between C and C++.
    --
    Greg Comeau / Comeau C++ 4.3.3, for C++03 core language support
    Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
    World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
    Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
    Greg Comeau, Dec 12, 2004
    #19
  20. Alf P. Steinbach

    Jon Bell Guest

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


    Mac OS X does not come with a C++ compiler (or indeed any compilers)
    installed by default. However, retail packages of OS X include an "XCode
    Tools" CD that can be installed as an option. It includes a suite of
    development tools including a C++ compiler (g++). Disk images of that CD
    can also be downloaded for free from Apple's Web site.

    --
    Jon Bell <> Presbyterian College
    Dept. of Physics and Computer Science Clinton, South Carolina USA
    Jon Bell, Dec 13, 2004
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alf P. Steinbach
    Replies:
    28
    Views:
    801
    Alf P. Steinbach
    Dec 18, 2004
  2. Alf P. Steinbach
    Replies:
    13
    Views:
    663
    Alf P. Steinbach
    Feb 1, 2005
  3. Alf P. Steinbach
    Replies:
    7
    Views:
    3,058
    chris
    Jan 24, 2005
  4. Alf P. Steinbach
    Replies:
    10
    Views:
    772
    Alf P. Steinbach
    Feb 23, 2005
  5. Alf P. Steinbach
    Replies:
    2
    Views:
    527
    Alf P. Steinbach
    Feb 22, 2005
Loading...

Share This Page