help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string.h included in iostream


From: red floyd
Subject: Re: string.h included in iostream
Date: Mon, 16 Oct 2006 15:44:53 GMT
User-agent: Thunderbird 1.5.0.7 (Windows/20060909)

r.gmail wrote:
Hi all,
  when I try to compile the following simple code:

#include <iostream>

int main () {

  if (index > 0) {
    std::cout << "Here" << std::endl;
  }

  return 0;
}

using g++ 3.3.5 (Debian 1:3.3.5-13) version and also g++ version  4.1.1
(Fedora core 5), I don't have any warnings or errors during the
compilation and the executable works fine, just prints "Here" to
stdout.
  I suppose it works, using instead of "index", any other extern
symbols defined in string.h or strings.h (simply the "compiler"
compares the address of such functions with a null).
  My question is is it a standard behavior ? Should string.h be
included in iostream ?


I believe that's implementation dependent. Your code, as posted, is ill-formed (index is undefined). As far as I can see, ISO/IEC 14882:2003 provides no guarantees as to what nested includes are in any standard header (hence the technical need to include <ostream> for cout).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]