Results 1 to 9 of 9

Thread: warning during compilation of a C program

  1. #1
    Junior Member
    Join Date
    Sep 2006
    Posts
    70

    warning during compilation of a C program

    I compiled a file on a fedora OS using g++ program. Though the file was successfully compiled i see the following warning. Please explain this warning for me. Thank in advance!!


    In file included from /usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c ++/4.0.0/backward/iostream.h:31,
    from helloworld.cpp:1:
    /usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/backward/back ward_warning.h:32:2: warning: #warning This file includes at least one deprecate d or antiquated header. Please consider using one of the 32 headers found in sec tion 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated h eader <iostream.h>. To disable this warning use -Wno-deprecated.

  2. #2
    I'm guessing one of the first things in your program is #include <iostream.h>? You should be using: #include <iostream>, it should compile faster. I think the difference is with the .h it has to compile the header, and with the other one it just links to the library. I could be mistaken though.
    63,000 bugs in the code, 63,000 bugs,
    ya get 1 whacked with a service pack,
    now there&#039;s 63,005 bugs in the code!!

  3. #3
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    It's the same compilation wise if you use
    #include <header.h>
    vs
    #include <header>
    But C++ langauge specific states, that you shuldn't use .h when you include headers provided by the system.

    It's actualy very simple, in your system provided iostream.h theres a line ie:
    Code:
    #include "backward_warning.h"
    And this backward_warning header, will detect if the compiler has the __DEPRICATED flag set. If it does, it will display the warning you're seeing.
    Basicaly teh file contains:
    Code:
    #ifdef __DEPRECATED
    #warning This file includes at least one deprecated or antiquated header. \
    Please consider using one of the 32 headers found in section 17.4.1.2 of the \
    C++ standard. Examples include substituting the <X> header for the <X.h> \
    header for C++ includes, or <iostream> instead of the deprecated header \
    <iostream.h>. To disable this warning use -Wno-deprecated.
    #endif
    As you might have noticed by now, having a line with #warning in your code, results in the compiler returning that line as a compiler warning.

    It's common used, if you have a huge code base, and you're playing around, then while trying some quick-fix hacked together you might add a line like:
    Code:
    #warning Please reconsidder if this is the correct way to do X
    And while you're compiling you're beeing reminded that specific part might need a closer reconsidderation, then when having to weed out all these things in your code, you can search for that specific warning and know you'll be taken to the portion you want to investigate.
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

  4. #4
    Junior Member
    Join Date
    Sep 2006
    Posts
    70
    Quote Originally Posted by redhead View Post
    It's the same compilation wise if you use
    As you might have noticed by now, having a line with #warning in your code, results in the compiler returning that line as a compiler warning.

    It's common used, if you have a huge code base, and you're playing around, then while trying some quick-fix hacked together you might add a line like:
    Code:
    #warning Please reconsidder if this is the correct way to do X
    And while you're compiling you're beeing reminded that specific part might need a closer reconsidderation, then when having to weed out all these things in your code, you can search for that specific warning and know you'll be taken to the portion you want to investigate.
    Interesting. I found that if I use <header> instead of <header.h> and "using namespace std;" just after I declare headers I do not get the warning anymore

  5. #5
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    Thats because you're using a different header than the deprecated one, ie:
    Deprecated: /usr/include/c++/4.1.2/backward/iostream.h
    Actual: /usr/include/c++/4.1.2/iostream
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

  6. #6
    Junior Member
    Join Date
    Sep 2006
    Posts
    70
    Quote Originally Posted by redhead View Post
    Thats because you're using a different header than the deprecated one, ie:
    Deprecated: /usr/include/c++/4.1.2/backward/iostream.h
    Actual: /usr/include/c++/4.1.2/iostream
    yeah, and also I did not mention the namespace I want to use. i.e I was not putting in this line:
    using namespace std;

  7. #7
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    That can be ommited, if you use std:: infront of everything you're using from the std namespace.
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

  8. #8
    Junior Member
    Join Date
    Sep 2006
    Posts
    70
    Quote Originally Posted by redhead View Post
    That can be ommited, if you use std:: infront of everything you're using from the std namespace.
    ofcourse you are right Readhead. but you won't like to write std:: in front of each and every function that you use.

  9. #9
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    if you're part of a larger group working on the same project, you need to have control of what namespace you're working within, if someone decides to rewrite a std1 namespace which has a mangeling of cout/cin, and you're on some level is including his header defining this mangeling, as well as stating "using namespace std1", then when you state "using namespace std" you can't be sure if it will be the system std or his mangeling you're using.

    So for good practice, I like to write specificaly what namspace I'm adressing in my code.
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

Similar Threads

  1. Compilation problem with c++ program
    By mountainman in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 04-15-2005, 06:53 AM
  2. Compilation of IDE's
    By SkyNet in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 05-01-2004, 09:26 PM
  3. Apache 2 compilation
    By vwgtiturbo in forum Linux - Software, Applications & Programming
    Replies: 0
    Last Post: 02-02-2004, 07:33 AM
  4. compilation (in general)
    By tetrahymenix in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 01-19-2003, 04:08 AM
  5. Port Scan Warning Program?
    By datamike in forum Linux - Hardware, Networking & Security
    Replies: 4
    Last Post: 03-27-2002, 06:52 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •