Topic: What is a STANDARD program, WAS: We have a standard!
Author: AllanW@my-dejanews.com
Date: 1998/08/04 Raw View
In article <6pps07$p4m$1@nnrp1.dejanews.com>,
ScottGregory@my-dejanews.com wrote:
> I think that 'we' as a community should care how they do it. While
> the C++ standard does not define a window API, there are mechanisims
> for libraries and including source. There are mechanisms that many
> compiler vendors have built for shared objects/libs that do not
> require language extension, etc.
Right. And the standard doesn't stop this.
> The statement "any C++ program which does windowing isn't
> conforming anyway" seems a little strange. That would imply that
> because there was nothing in the standard for printing the Hello
> World to somewhere then it must be a non-conforming program?
Don't read too much into it. "Isn't conforming" does not imply "bad".
A program that conforms to the C++ standard can be compiled anywhere,
on any compliant C++ compiler.
The moment you #include <windows.h> in your program, you no longer
have a C++ standard program, and you can't expect it to compile on
just any C++ compiler. You may indeed have a standard Windows program,
capable of compiling on any Windows compiler. Obviously, the C++
standard cannot and does not dictate what requirements a Windows
program must follow.
(Maybe someday we'll have an ANSI/ISO Windows standard. Such a standard
might indeed have a reference to ANSI/ISO C++, just as ANSI/ISO C++ has a
reference to ANSI/ISO C. But that's a different story.)
The moment you #include "date.h" in your program, if you didn't write
"date.h" yourself, then you no longer have a C++ standard program, and
you can't expect it to compile on just any C++ compiler. You may indeed
have a standard Rogue-Wave program, capable of compiling on any C++
compiler that also has Rogue Wave's library installed. You could also make
your program into a standard C++ program by writing "date.h" and all
related files yourself.
And so on. The standard doesn't say that you should never use third-party
libraries. It simply states the minimum requirements for any compliant
compiler. If your programs follow all of these rules, you have a
well-formed program that should compile and execute correctly on any
complaint compiler.
> So can I have a 'standard' program that uses libraries only available on one
> machine? I would think yes.
By definition, no. But this non-standard program can easily be more useful
than a standard one would have been.
For instance, you write a Windows program called Math Nuk'em. (You have
to shoot certain Aliens with the right numbers on their ships). It looks
really spiffy, too, but it won't work on just any old C++ compiler. It
needs a C++ compiler for Windows, because it's a non-standard program.
Your friend wrote a program which proves that a certain number is the
largest known prime number. While it runs, it prints a dot every 10
seconds to let you know how far it's gotten. It doesn't do anything
flashy, but like all standard-conforming programs, it works on any
compliant C++ compiler.
Which is better? Neither one! Your friend just won a $50,000 scholarship
from a major university, but your program is bought by Broderbund and
you start collecting royalties. Both of these programs have a place in
our world.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Paul D. DeRocco" <pderocco@ix.netcom.com>
Date: 1998/08/04 Raw View
ScottGregory@my-dejanews.com wrote:
>
> The statement "any C++ program which does windowing isn't
> conforming anyway" seems a little strange. That would imply that
> because there was nothing in the standard for printing the Hello World
> to somewhere then it must be a non-conforming program?
>
> AFAIK I can write ANSI C X-Windows code, and can probably therefore
> write conforming C++ code as well. (I can also compile it on NT if I
> want to.)
Fully conforming C++ code has a main() function. Windows uses something
else.
But anyway, the only purpose of having a standard is to allow
portability. If you're writing for Windows, you only need to be portable
across the various flavors of Windows, so there's no intrinsic problem
with extensions added by Microsoft, as long as they're supported in all
those flavors.
--
Ciao,
Paul
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: James Kuyper <kuyper@wizard.net>
Date: 1998/08/04 Raw View
ScottGregory@my-dejanews.com wrote:
...
> The statement "any C++ program which does windowing isn't
> > conforming anyway" seems a little strange. That would imply that because
>
> there was nothing in the standard for printing the Hello World to somewhere
> then it must be a non-conforming program?
The facilities needed to print Hello World are part of the standard
library. That is not true of the X functions, nor of the Windows
functions. A strictly conforming program can't call those functions,
because a conforming implementation needn't provide them.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: ScottGregory@my-dejanews.com
Date: 1998/08/01 Raw View
Hope the mailer keeps the attributions correct...
In article <6pncqi$mfe$1@nnrp1.dejanews.com>,
kanze@my-dejanews.com wrote:
> In article <199807281217.IAA27606@mailfw1.ford.com>,
> Mike Tiller <mtiller@ford.com> wrote:
> > kanze@my-dejanews.com writes:
> >
> > Microsoft may hack all sorts of proprietary features into their
> > compilers to support their GUI API, but that is definitely not the way
> > X does it.
>
> Who cares how they do it? The point is simple: the C++ standard does
> not define a windowing API, so any C++ program which does windowing isn't
> conforming anyway.
I think that 'we' as a community should care how they do it. While the C++
standard does not define a window API, there are mechanisims for libraries and
including source. There are mechanisms that many compiler vendors have built
for shared objects/libs that do not require language extension, etc.
The statement "any C++ program which does windowing isn't
> conforming anyway" seems a little strange. That would imply that because
there was nothing in the standard for printing the Hello World to somewhere
then it must be a non-conforming program?
AFAIK I can write ANSI C X-Windows code, and can probably therefore write
conforming C++ code as well. (I can also compile it on NT if I want to.)
So can I have a 'standard' program that uses libraries only available on one
machine? I would think yes.
Can I have a 'standard' program that uses non-standard language extentions? I
would think no. (Then again one could argue that as long as the preprocessor
can strip out the offending bits, then it might well be a conforming program.)
So what is a 'conforming' program?
sdg
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]