Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > a console application in C++

Reply
Thread Tools

a console application in C++

 
 
James Kanze
Guest
Posts: n/a
 
      07-17-2007
On Jul 17, 12:24 am, Lionel B <(E-Mail Removed)> wrote:
> On Mon, 16 Jul 2007 17:41:01 +0000, Default User wrote:
> > Lionel B wrote:


> >> I used to use -ansi rather than -std=c++98 until it was pointed out to
> >> me (on this ng) that -std=c++98 is probably more appropriate; ISO is an
> >> international standardisation organisation, while ANSI is US only.


> >> Apart from which I've actually just had a look at the GCC manual and it
> >> doesn't say what -ansi does (if anything) for C++ - it only specifies
> >> the ISO 1990 C standard, apparently...


> > From the Solaris man pages:


> > -ansi
> > In C mode, support all ISO C90 programs. In C++ mode, remove
> > GNU extensions that conflict with ISO C++.


> Right, just found that. So it seems that for C++ -ansi *is* actually
> equivalent to -std=c++98.


At present. What will it mean when they also support
-std=c++03?

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

 
Reply With Quote
 
 
 
 
James Kanze
Guest
Posts: n/a
 
      07-17-2007
On Jul 16, 1:19 pm, arnuld <(E-Mail Removed)> wrote:

[...]
> i want to create some console programme,


The problem is that the concept of a console program (as opposed
to some other type of program) is purely Windows. On most
systems, a program is a program, and C++ doesn't make any real
distinction.

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

 
Reply With Quote
 
 
 
 
Lionel B
Guest
Posts: n/a
 
      07-17-2007
On Tue, 17 Jul 2007 09:59:42 +0000, James Kanze wrote:

> On Jul 16, 11:50 am, Lionel B <(E-Mail Removed)> wrote:
>> On Mon, 16 Jul 2007 09:07:59 +0000, arnuld wrote:

>
> [...]
>> Note: the "-std=c++98 -pedantic" flags ensure that you are compiling
>> according to the current C++ standard without any GCC-specific
>> extensions/ restrictions to the language.

>
> Note that the "-std=c++98 -pedantic" flags only affect the compiler, and
> do *not* ensure that you are not including non-standard headers or
> linking against non-standard libraries.


No indeed, they only specify the *language* standard that the compiler
should respect.

[...]

To summarise: the only way to ensure that you are not including non-
standard headers or linking against non-standard libraries is ... don't
include non-standard headers and don't link against non-standard
libraries.

--
Lionel B
 
Reply With Quote
 
Lionel B
Guest
Posts: n/a
 
      07-17-2007
On Tue, 17 Jul 2007 10:07:24 +0000, James Kanze wrote:

> On Jul 17, 12:24 am, Lionel B <(E-Mail Removed)> wrote:
>> On Mon, 16 Jul 2007 17:41:01 +0000, Default User wrote:
>> > Lionel B wrote:

>
>> >> I used to use -ansi rather than -std=c++98 until it was pointed out
>> >> to me (on this ng) that -std=c++98 is probably more appropriate; ISO
>> >> is an international standardisation organisation, while ANSI is US
>> >> only.

>
>> >> Apart from which I've actually just had a look at the GCC manual and
>> >> it doesn't say what -ansi does (if anything) for C++ - it only
>> >> specifies the ISO 1990 C standard, apparently...

>
>> > From the Solaris man pages:

>
>> > -ansi
>> > In C mode, support all ISO C90 programs. In C++ mode,
>> > remove GNU extensions that conflict with ISO C++.

>
>> Right, just found that. So it seems that for C++ -ansi *is* actually
>> equivalent to -std=c++98.

>
> At present. What will it mean when they also support -std=c++03?


Who knows? Maybe then the g++ default will be -std=gnu++03' which will be
the same as -std=c++03 plus GNU extensions and if -ansi removes those
extensions you'll be left with -std=c++03?

Maybe they should have a flag -std=c++latest-supported (and then make
that the sodding default, rather than forcing you to mess about to get
standard behaviour).

--
Lionel B
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      07-18-2007
On Jul 17, 12:21 pm, Lionel B <(E-Mail Removed)> wrote:
> On Tue, 17 Jul 2007 10:07:24 +0000, James Kanze wrote:
> > On Jul 17, 12:24 am, Lionel B <(E-Mail Removed)> wrote:
> >> On Mon, 16 Jul 2007 17:41:01 +0000, Default User wrote:
> >> > Lionel B wrote:


> Who knows? Maybe then the g++ default will be -std=gnu++03' which will be
> the same as -std=c++03 plus GNU extensions and if -ansi removes those
> extensions you'll be left with -std=c++03?


But perhaps for some older code, you'll still want -std=c++98.
I sort of suspect that this option was introduced for C, where
some people definitely only want C90, where as gcc tries to
support C99. The point is, you have a choice.

> Maybe they should have a flag -std=c++latest-supported (and then make
> that the sodding default, rather than forcing you to mess about to get
> standard behaviour).


That sounds like a very good idea---why don't you propose it to
them. Adding a "-std=<lang>-latest" option sounds like a simple
and obvious improvement. With regards to the default: from what
I can tell, the C++ group are moving in the direction of
deprecating (and perhaps sometime eliminating) the GNU
extensions, so the number of extensions you get is going down.
What's really missing is:
-- that the option also affect the library, and
-- options for other standards, like Posix.
(I would expect that the default on a Unix machine also include
-std=posix<version>. Even when that contradicts -std=c++98.)
The problem with this is that on most platforms, the library, or
at least the C part of it) is beyond the reach of g++ itself.
The best the OS option could do is set the appropriate -D
options and (if necessary) the library path.

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      07-18-2007
On Jul 17, 12:10 pm, Lionel B <(E-Mail Removed)> wrote:
> On Tue, 17 Jul 2007 09:59:42 +0000, James Kanze wrote:
> > On Jul 16, 11:50 am, Lionel B <(E-Mail Removed)> wrote:
> >> On Mon, 16 Jul 2007 09:07:59 +0000, arnuld wrote:


> > [...]
> >> Note: the "-std=c++98 -pedantic" flags ensure that you are compiling
> >> according to the current C++ standard without any GCC-specific
> >> extensions/ restrictions to the language.


> > Note that the "-std=c++98 -pedantic" flags only affect the compiler, and
> > do *not* ensure that you are not including non-standard headers or
> > linking against non-standard libraries.


> No indeed, they only specify the *language* standard that the compiler
> should respect.


The "International Standard: Programming Languages -- C++",
ISO:IEC 14882 also defines what we traditionally would call a
library. From the point of view of the standard, the library is
part of the language (and is certainly part of the language
standard).

> [...]


> To summarise: the only way to ensure that you are not including non-
> standard headers or linking against non-standard libraries is ... don't
> include non-standard headers and don't link against non-standard
> libraries.


Yup.

There are a lot of other bad practices that the compiler will
accept as well. (Things like indirectly returning a reference
to a local variable, for example.) Specifying "-std=c++98
-pendantic" is very useful. So are "-D_GLIBCXX_CONCEPT_CHECKS
-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC". But you still need
good code review.

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Starting a GUI application out of an console application Fabian Steiner Python 1 07-17-2006 05:01 PM
A simple Console Application to ASP.NET application Web learner ASP .Net 1 01-27-2006 03:09 AM
How to start ASP.Net application from console application? Mike ASP .Net 9 11-30-2005 12:26 AM
Re: console mp3->wav decoder for $indows or GUI one which supports console Egor Bolonev Python 0 06-30-2003 10:43 AM
Re: console mp3->wav decoder for $indows or GUI one which supports console Ben Finney Python 2 06-30-2003 05:43 AM



Advertisments