Thread: compilation prob?

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    142

    compilation prob?

    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    #include <sstream>
    
    
    int main()
    {
    
    
    
    stringstream ss;
    
    string data;
    
    
    ifstream in;
    in.open("stores.ddf");
    
    ss << afile.rdbuf();
    
    
    
    }
    i tried to compile this but it said that there is no such file reagarding <sstream>

    what have i done?


    cheers.
    WhAtHA hell Is GoInG ON

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Well, what compiler? You are also not using any std:: anywhere and there is no afile stream object anywhere.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    142
    Quote Originally Posted by hk_mp5kpdw
    Well, what compiler? You are also not using any std:: anywhere and there is no afile stream object anywhere.
    still a noob, i'm using DEV-c++.
    WhAtHA hell Is GoInG ON

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    You either created a C project instead of a C++ one or you have a bad Dev-C++ setup.

    Right-Click the project name on the left-hand side list. Choose Project Options->Files Tab. Select the cpp file and make sure "Compile file as C++" is checked. If you still have the same problem, or it is already checked, go to Tools Menu->Compiler Options->Directories Tab->C++ Includes Tab and tell us what paths it has listed.

    Also, when creating new projects make sure you specify them as C++ on the first dialog screen.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #5
    Registered User
    Join Date
    Sep 2005
    Posts
    142
    Quote Originally Posted by Mario F.
    You either created a C project instead of a C++ one or you have a bad Dev-C++ setup.

    Right-Click the project name on the left-hand side list. Choose Project Options->Files Tab. Select the cpp file and make sure "Compile file as C++" is checked. If you still have the same problem, or it is already checked, go to Tools Menu->Compiler Options->Directories Tab->C++ Includes Tab and tell us what paths it has listed.

    Also, when creating new projects make sure you specify them as C++ on the first dialog screen.
    thanks, it's obveously the compiler it's self because i put the code into another compiler and it worked, <fstream> didn't return an error so it woudn't be in C right?
    WhAtHA hell Is GoInG ON

  6. #6
    Moderately Rabid Decrypt's Avatar
    Join Date
    Feb 2005
    Location
    Milwaukee, WI, USA
    Posts
    300
    What version of Dev-C++ are you using? The 4.9.whatever one doesn't come with it. Get the v5 instead.
    There is a difference between tedious and difficult.

  7. #7
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    What version of Dev-C++ are you using? The 4.9.whatever one doesn't come with it. Get the v5 instead.
    I assummed 4.992 was the final version of dev. Bloodshed abandoned any more versions
    Double Helix STL

  8. #8
    Registered User
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    267
    Quote Originally Posted by http://bloodshed.net/dev/devcpp.html
    Dev-C++ 5.0 beta 9.2 (4.9.9.2) (9.0 MB) with Mingw/GCC 3.4.2
    its the same thing

    OS: Windows 7, XUbuntu 11.10, Arch Linux
    IDE: CodeBlocks
    Compiler: GCC

  9. #9
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    > thanks, it's obveously the compiler it's self because i put the code into another compiler and it worked, <fstream> didn't return an error so it woudn't be in C right?

    Compiling from another place will not solve the problem nor will it tell you what is wrong. Do the tests I suggested you previously.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  10. #10
    Registered User
    Join Date
    Sep 2005
    Posts
    142
    Quote Originally Posted by Mario F.
    > thanks, it's obveously the compiler it's self because i put the code into another compiler and it worked, <fstream> didn't return an error so it woudn't be in C right?

    Compiling from another place will not solve the problem nor will it tell you what is wrong. Do the tests I suggested you previously.

    Dude, thats not what i'm saying, since <fstream> is a c++ function it would not work when compiling C code right?, so there for i didn't tell the compiler i was creating a c programme.

    i don't understand what you mean you seem to be very knowledgable when it comes to c++ programming so you should understand the logics in the elimination process,

    if <sstream> isn't working in one compiler but does in another it must be the compiler, as for the reason behind why the compiler doesn't accept the header <sstream> ........ knows.

    is there anything wronge with my methods?
    WhAtHA hell Is GoInG ON

  11. #11
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Thats down to either the compiler vendors, or the header librarys contained in the include directorys of that particular compiler. No compiler to my knowledge is fully C++ compliant. Many of the MS ones have almost all avalaible header files. DevC++ has the vast majority of them.

    One option to check if your particular compiler has sstream is to look in the folder containing the pre-made header files. If sstream is indeed included, then it "should" reconsize it as a valid header. Since C++ has backward compatability with C, if you create a C++ project or even a C++ source file, any C headers will be reconized.

    If on the other hand the include folder does not contain sstream, then you know it is down the compiler vendors choosing not to include it as a header library. Since Dev is quite old, getting patches and updates for it is impossible. Although with a MS IDE you get the ability to download platform SDK's and toolkits. If all else fails, this may be a logical solutuon
    Double Helix STL

  12. #12
    Registered User
    Join Date
    Sep 2005
    Posts
    142
    Quote Originally Posted by swgh
    Thats down to either the compiler vendors, or the header librarys contained in the include directorys of that particular compiler. No compiler to my knowledge is fully C++ compliant. Many of the MS ones have almost all avalaible header files. DevC++ has the vast majority of them.

    One option to check if your particular compiler has sstream is to look in the folder containing the pre-made header files. If sstream is indeed included, then it "should" reconsize it as a valid header. Since C++ has backward compatability with C, if you create a C++ project or even a C++ source file, any C headers will be reconized.

    If on the other hand the include folder does not contain sstream, then you know it is down the compiler vendors choosing not to include it as a header library. Since Dev is quite old, getting patches and updates for it is impossible. Although with a MS IDE you get the ability to download platform SDK's and toolkits. If all else fails, this may be a logical solutuon
    What compiler would you recommend? i have been using DEV- since i started but it is starting to limit what i can do !
    WhAtHA hell Is GoInG ON

  13. #13
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Assuming you are using the latest version, Dev-C++ and the compiler that comes with it is fine.

    The original code posted is wrong because it doesn't specify the std namespace. Otherwise it should work.

    If it doesn't work and you are using the latest version of Dev-C++, it is not the compiler's problem, it is an error with how you are using it. Other than the need to add the std namespace, there's nothing obvious that you are doing wrong that we can see.

  14. #14
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    Just my two cents, it's true that without specifying the std namespace, it will become an error. However, the error message will be different with what wart101 experienced. There's one other possibility. Maybe the installation of the compiler was corrupt or something. Try reinstalling the compiler and see how it compiles again. I have a similar issue before with a corrupt Visual C++ 6. And when I reinstalled the Visual Studio, it worked fine.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  15. #15
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    I echo that problem g4j31a5. When I first installed that same software at college and ran my larger programs, I kept getting an error up saying the software had encountered a problem. Even 2005 version has done it a once. It a little glitch we have to put up with once in a while. Best idea is to make sure you save the files regually. Then, if it does crash, you will not lose much of what you just did.
    Double Helix STL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deal or No Deal listbox prob
    By kryptkat in forum Windows Programming
    Replies: 5
    Last Post: 03-30-2009, 06:53 PM
  2. Replies: 3
    Last Post: 11-20-2008, 12:31 PM
  3. Compilation units
    By filler_bunny in forum C++ Programming
    Replies: 0
    Last Post: 10-21-2003, 03:57 AM
  4. MS VC++ Crash on compilation
    By Magos in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 08-23-2003, 07:06 PM
  5. malloc problem in SUN in 64-bit compilation
    By ylzhang in forum C Programming
    Replies: 6
    Last Post: 05-31-2003, 11:48 AM