What is #include_next

This is a discussion on What is #include_next within the C++ Programming forums, part of the General Programming Boards category; I accidentally compiled these headers in a simple test program I was running to get a better understanding of strtok: ...

  1. #1
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396

    What is #include_next

    I accidentally compiled these headers in a simple test program I was running to get a better understanding of strtok:

    Code:
    #include <string.h>
    #include <iostream>
    #include <cstring>

    And I received this warning:
    warning: #include_next is a GCC extension.

    I Googled and found out that it is a GCC extension, well that is quite obvious from the warning I received but what exactly does it mean or do?

    If I get rid of the string.h header (which is what I meant to do ) or include it after iostream this warning goes away! This leads me to another question is there a case where one would need to include to similar header files like string.h and cstring?

    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    <cstring> isn't necessarily the same as <string.h>.

    I've never actually seen that warning before, but usually, if you're writing C++, use the <cname> header instead of the <name.h> header... usually each header includes whatever headers it needs... for example, if you crack open some of the standard headers you include, you'll find it's nothing more than more includes and maybe a few typedefs.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Standard header files don't end with a .h, so remove that and see if you still get the error.

    This leads me to another question is there a case where one would need to include to similar header files like string.h and cstring?
    Yep. A standard header file contains functions, definitions, etc., so if you want to use the functions or definitions in those header files, then you have to include them. Here is an example:
    Code:
    string name = "Tom"; //string type defined in <string>
    name += " Smith";  //string function "+=" defined in <string>
    
    cout<<name<<endl; //cout, endl, and function "<<" defined in <iostream>
    
    char flower[] = "tulip";
    cout<<strlen(flower)<<endl; //strlen() defined in <cstring>
    Last edited by 7stud; 10-20-2005 at 01:03 AM.

  4. #4
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    I think he meant would there be a case where he need to include <string.h> and <cstring> in the same program...

    edit: as for the whole "GCC Extension" thing... I don't know too much about it, but from the very little bit I've picked up, it sounds like some extra stuff the GCC compiler lets you do... each compiler has it's own ways of doing things, and some compilers allow non-standard things (like clrscr()). I'm guessing a "GCC Extension" is just something that the GCC compiler lets you do, but isn't really standard and may not work on other compilers.

    if you got that while you were using Dev-C++, that would make sense because Dev-C++ uses a MingW port of GCC (which is native to linux)
    Last edited by major_small; 10-20-2005 at 01:07 AM.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  5. #5
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396
    Thanks for the input, I realize that I was using a deprecated header. I'm used to c programming not c++ and it is just a habit. Hell, I keep typing printf instead of cout. Oh well, practice makes perfect!
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21