Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. STL problem

STL problem

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dor
    wrote on last edited by
    #1

    Hi, Im trying to use STL in my MFC program in VC++. It keeps on giving me errors. Im sure there is a simple way to fix it, but i have no idea what that way is. Can someone help? Cheers Dor

    T 1 Reply Last reply
    0
    • D Dor

      Hi, Im trying to use STL in my MFC program in VC++. It keeps on giving me errors. Im sure there is a simple way to fix it, but i have no idea what that way is. Can someone help? Cheers Dor

      T Offline
      T Offline
      Taka Muraoka
      wrote on last edited by
      #2

      Well, unless you give us some details of the problem, you might be better off trying here[^]... :-)


      he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.

      R 1 Reply Last reply
      0
      • T Taka Muraoka

        Well, unless you give us some details of the problem, you might be better off trying here[^]... :-)


        he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.

        R Offline
        R Offline
        RobJones
        wrote on last edited by
        #3

        Taka Muraoka wrote: you might be better off trying here[^]... LOL Yeah please post the error you are getting..

        D 1 Reply Last reply
        0
        • R RobJones

          Taka Muraoka wrote: you might be better off trying here[^]... LOL Yeah please post the error you are getting..

          D Offline
          D Offline
          Dor
          wrote on last edited by
          #4

          Well, i include all the right things and it gives me this error on the line that i declare the list object on: c:\program files\microsoft visual studio\vc98\include\ios.h(146) : error C2872: 'streambuf' : ambiguous symbol I know that the code works when its not using MFC, this error only comes up when in an MFC project Cheers Dor

          T 1 Reply Last reply
          0
          • D Dor

            Well, i include all the right things and it gives me this error on the line that i declare the list object on: c:\program files\microsoft visual studio\vc98\include\ios.h(146) : error C2872: 'streambuf' : ambiguous symbol I know that the code works when its not using MFC, this error only comes up when in an MFC project Cheers Dor

            T Offline
            T Offline
            Taka Muraoka
            wrote on last edited by
            #5

            This is almost certainly caused by your having #include'd mismatching files. Most STL objects come in two versions, one that lives in the global namespace (this is the old style) that you get by #include'ing <iostream.h> The newer version lives in the std namespace - you this by #include'ing <iostream> (nb: no ".h") So if you #include *both* files and have a using namespace std directive somewhere, when the compiler finds a reference to an STL class, streambuf in your case, it has two matching possibilities i.e. ::streambuf and std::streambuf and doesn't know which one to use.


            he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.

            D 1 Reply Last reply
            0
            • T Taka Muraoka

              This is almost certainly caused by your having #include'd mismatching files. Most STL objects come in two versions, one that lives in the global namespace (this is the old style) that you get by #include'ing <iostream.h> The newer version lives in the std namespace - you this by #include'ing <iostream> (nb: no ".h") So if you #include *both* files and have a using namespace std directive somewhere, when the compiler finds a reference to an STL class, streambuf in your case, it has two matching possibilities i.e. ::streambuf and std::streambuf and doesn't know which one to use.


              he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.

              D Offline
              D Offline
              Dor
              wrote on last edited by
              #6

              But the #include only appears once in the project. should i be using using namespace std; with this version, and should it appear in the header file of the class, and should it be global or local to the class? sorry, im bombarding you with questions! Cheers Dor

              T 1 Reply Last reply
              0
              • D Dor

                But the #include only appears once in the project. should i be using using namespace std; with this version, and should it appear in the header file of the class, and should it be global or local to the class? sorry, im bombarding you with questions! Cheers Dor

                T Offline
                T Offline
                Taka Muraoka
                wrote on last edited by
                #7

                You need to be careful when typing in #include statements here. the < looks like the start of an HTML tag and doesn't get processed properly - use < Never put "using namespace std" in a header file - it should always go in the .cpp file, *after* all your #include's. It is not something that is global/local to a class but instead something that relates to an entire file, during the compilation process. This kind of thing is almost impossible to track down without having access to a full copy of the source. The reason why it is working previously but not with MFC is that MFC is #include'ing its own version of the STL headers, probably the old .h ones while your code is #include'ing the new ones. I would try fiddling around with your #include's. You might want to turn off pre-compiled headers while you're doing this since it will almost certainly cause you grief :-)


                he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.

                D 1 Reply Last reply
                0
                • T Taka Muraoka

                  You need to be careful when typing in #include statements here. the < looks like the start of an HTML tag and doesn't get processed properly - use < Never put "using namespace std" in a header file - it should always go in the .cpp file, *after* all your #include's. It is not something that is global/local to a class but instead something that relates to an entire file, during the compilation process. This kind of thing is almost impossible to track down without having access to a full copy of the source. The reason why it is working previously but not with MFC is that MFC is #include'ing its own version of the STL headers, probably the old .h ones while your code is #include'ing the new ones. I would try fiddling around with your #include's. You might want to turn off pre-compiled headers while you're doing this since it will almost certainly cause you grief :-)


                  he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.

                  D Offline
                  D Offline
                  Dor
                  wrote on last edited by
                  #8

                  Cool, Thanks heaps for you help Dor

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups