473,395 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Diagnostic required?

Is a conforming C++ implementation required to issue a diagnostic when
invoked on the following code?

#include <cstdlib>
#include <iostream>
#include <string>

int main()
{
printf( "Hello, world!\n" ); // oops, <cstdio> missing
return( EXIT_SUCCESS );
}

g++ -Wall -ansi -pedantic does not; I'm wondering if I have cause for
a bug report (assuming one has not yet been submitted).

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #1
2 1201
On Sun, 10 Oct 2004 20:40:09 +0000 (UTC), Christopher Benson-Manica
<at***@nospam.cyberspace.org> wrote in comp.lang.c++:
Is a conforming C++ implementation required to issue a diagnostic when
invoked on the following code?
No.
#include <cstdlib>
#include <iostream>
#include <string>

int main()
{
printf( "Hello, world!\n" ); // oops, <cstdio> missing
return( EXIT_SUCCESS );
}

g++ -Wall -ansi -pedantic does not; I'm wondering if I have cause for
a bug report (assuming one has not yet been submitted).


This is one of the differences between C and C++. The C language
standard specifically forbids any standard header from including any
other standard header. On the other hand, the C++ standard
specifically allows any standard header to include any other standard
header.

So on your particular version of g++, one or more of <csdtlib>,
<iostream>, or <string> includes <stdio.h>. Most likely <iostream>,
but you never know. In which case, no diagnostic is required or even
warranted.

So there is no guarantee that any other conforming implementation will
compile this successfully, because other implementations might not
include <stdio.h>.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jul 22 '05 #2
Jack Klein <ja*******@spamcop.net> spoke thus:
So there is no guarantee that any other conforming implementation will
compile this successfully, because other implementations might not
include <stdio.h>.


Well, probably none will include <stdio.h>, but they might include
<cstdio> :) Thanks for the answer.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: KiwiBrian | last post by:
I have a snippet of a few CSS rules that I insert in a page as a diagnostic tool It places borders around specified tags. However I have been unable to get it to display borders on table rows. Is...
0
by: Stefan Turalski \(stic\) | last post by:
Hi, I need help with one thing - I've simple update application, it's chceck with FineInfo class if file in server has last write time > than file on my disc, if yes it is just update my file...
2
by: adish11 | last post by:
I'm using Web Application and want to execute an MSDOS executable with some parameters like this example: software.exe -i -x How do I use System.Diagnostic.Process to execute this .exe with...
5
by: Michael Johnson Sr. | last post by:
I am starting and stopping a process using System.Diagnostic.Process. aspnet_wp is running as system rather than machine (as per machine.config modification). When the process gets started, it...
8
by: Man with Oscilloscope | last post by:
goto jumping over vla -- diagnostic required? This is a question about C99, 6.8.6.1, example 2 (see test below). I'm currently working on updating an older compiler up to C99. The standard is...
41
by: p_cricket_guy | last post by:
Please see this test program: 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <limits.h> 4 5 int main (void) 6 { 7 int y = -2147483648; 8 int x = INT_MIN;
11
by: Old Wolf | last post by:
Does the following program require a diagnostic? Which section of the Standard deals with this? (I read the section on function calls and didn't see anything). void f(void); int main(void) {...
5
by: santosh | last post by:
We are given the definition of a "diagnostic message" in 3.10 of the Standard. To quote: 3.10 1 diagnostic message message belonging to an implementation-defined subset of the implementation's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.