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

A

Alf P. Steinbach

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

Matthias =?ISO-8859-1?Q?K=E4ppler?=

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
 
?

=?iso-8859-1?q?Stephan_Br=F6nnimann?=

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
(e-mail address removed)
http://www.osb-systems.com
Open source rating and billing engine for
communication networks.
 
I

Ioannis Vranos

Alf said:
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.
 
I

Ioannis Vranos

Alf said:
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.
 
R

Rob Williscroft

Ioannis Vranos wrote in in comp.lang.c++:
#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.
 
R

Razzer

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

Rob Williscroft

Razzer wrote in in comp.lang.c++:
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.
 
M

Mike Wahler

Ioannis Vranos said:
#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
 
R

Razzer

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

Alf P. Steinbach

* Ioannis Vranos:
?


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

Alf P. Steinbach

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


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

Alf P. Steinbach

* =?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... ;-)
 
I

Ioannis Vranos

Alf said:
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++.
 
C

Chris Theis

[SNIP]
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
 
M

Matthias =?ISO-8859-1?Q?K=E4ppler?=

Alf said:
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.
 
G

Greg Comeau

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

Jon Bell

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.
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top