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. Problem with CString! CXX0017

Problem with CString! CXX0017

Scheduled Pinned Locked Moved C / C++ / MFC
helpcomdebuggingquestionworkspace
20 Posts 5 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.
  • C Cedric Moonen

    It's not because you can't see the value of str2 that you are not able to see where your program crashes. Maybe you are trying to watch str2 out of its scope. It can only be watched if you have a breakpoint in the function where it is declared. Outside it, its not visible.


    Cédric Moonen Software developer
    Charting control

    T Offline
    T Offline
    tanarnelinistit
    wrote on last edited by
    #8

    Cedric Moonen wrote:

    Maybe you are trying to watch str2 out of its scope. It can only be watched if you have a breakpoint in the function where it is declared. Outside it, its not visible

    But I try to watch the variable str2 inside the function and I can't. I know what ur trying to say, that's why I asked you if it's because of the multihtreading, is that why I can't see it's value?

    1 Reply Last reply
    0
    • C Christian Graus

      When you get an assert, the first step is to break into the code. If you can't work out what's wrong, the next step is to post the line number and even the actual line of code that's causing the assert. We need the line number and file as well, if we're to see it in context.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      T Offline
      T Offline
      tanarnelinistit
      wrote on last edited by
      #9

      Christian Graus wrote:

      We need the line number and file as well, if we're to see it in context.

      File wincore.cpp Line 883.

      C D 2 Replies Last reply
      0
      • T tanarnelinistit

        Christian Graus wrote:

        We need the line number and file as well, if we're to see it in context.

        File wincore.cpp Line 883.

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #10

        Use the callstack to see in which of YOUR function the code crashes. Then put a breakpoint at the begining of this function and step by step to see which instruction makes your program crash.


        Cédric Moonen Software developer
        Charting control

        T 1 Reply Last reply
        0
        • C Cedric Moonen

          Use the callstack to see in which of YOUR function the code crashes. Then put a breakpoint at the begining of this function and step by step to see which instruction makes your program crash.


          Cédric Moonen Software developer
          Charting control

          T Offline
          T Offline
          tanarnelinistit
          wrote on last edited by
          #11

          Cedric Moonen wrote:

          Use the callstack to see in which of YOUR function the code crashes. Then put a breakpoint at the begining of this function and step by step to see which instruction makes your program crash.

          The line that makes my program crash: if (str2=="FFFF00000000028C") m_pSet->m_Nume="Gigi"; else m_pSet->m_Nume="Ionica"; Because that's a line on which I have str2 the variable that is defined and initiated with a value, but which I can't see. -- modified at 8:53 Wednesday 26th July, 2006

          D C 2 Replies Last reply
          0
          • T tanarnelinistit

            Christian Graus wrote:

            We need the line number and file as well, if we're to see it in context.

            File wincore.cpp Line 883.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #12

            tanarnelinistit wrote:

            File wincore.cpp Line 883.

            This is apparently not with VC++ v6. Correct?


            "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

            "Judge not by the eye but by the heart." - Native American Proverb

            T 1 Reply Last reply
            0
            • T tanarnelinistit

              Cedric Moonen wrote:

              Use the callstack to see in which of YOUR function the code crashes. Then put a breakpoint at the begining of this function and step by step to see which instruction makes your program crash.

              The line that makes my program crash: if (str2=="FFFF00000000028C") m_pSet->m_Nume="Gigi"; else m_pSet->m_Nume="Ionica"; Because that's a line on which I have str2 the variable that is defined and initiated with a value, but which I can't see. -- modified at 8:53 Wednesday 26th July, 2006

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #13

              tanarnelinistit wrote:

              if (str2=="FFFF00000000028C") m_pSet->m_Nume="Gigi";

              Put a breakpoint on the if statement and single-step (F10) from there.


              "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

              "Judge not by the eye but by the heart." - Native American Proverb

              1 Reply Last reply
              0
              • T tanarnelinistit

                I use the folowing code to listen the com: void CMina_sView::OnListenCom1() { running = TRUE; AfxBeginThread(run,this); } void CMina_sView::ascultarea() { CSerial serial; LONG lLastError = ERROR_SUCCESS; DWORD dwBytesRead = 0 ; char szBuffer[21]; CString str2="jjk"; char of[5]= "Addd"; int i=10; const int nBuflen = sizeof(szBuffer)-1; lLastError = serial.Open(_T("COM1"),0,0,false); lLastError = serial.Setup(CSerial::EBaud9600,CSerial::EData8,CSerial::EParNone,CSerial::EStop1); lLastError = serial.SetMask(CSerial::EEventBreak | CSerial::EEventCTS | CSerial::EEventDSR | CSerial::EEventError | CSerial::EEventRing | CSerial::EEventRLSD | CSerial::EEventRecv); lLastError = serial.SetupReadTimeouts(CSerial::EReadTimeoutNonblocking); lLastError = serial.WaitEvent(); const CSerial::EEvent eEvent = serial.GetEventType(); if (eEvent & CSerial::EEventRecv) { while (running) {Sleep(300); dwBytesRead = 0; serial.Read(szBuffer,nBuflen,&dwBytesRead); szBuffer[dwBytesRead] = '\0'; str2.TrimLeft(); str2.TrimRight(); str2.TrimLeft(); str2.TrimRight(); // do smth with str2 } } //Sleep(0); running = FALSE; serial.Close(); } UINT CMina_sView::run(LPVOID p) { CMina_sView * me = (CMina_sView *)p; me->ascultarea(); return 0; } If I run the program I get an error. If I run it in debug mode I when try to watch str2 i get the error: "symbol "str2" not found" What's wrong? I can watch any other variable.

                J Offline
                J Offline
                James R Twine
                wrote on last edited by
                #14

                IME, symbol "str2" not found errors in the debugger are due to one of four things:      1: You typed the identifier incorrectly      2: You are in the wrong context      3: You are trying to view a static variable (VC++ 6.0)      4: You have overrun/underrun a buffer    Given that you are also getting additional errors, I would research #4.    Peace!

                -=- James


                If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                DeleteFXPFiles & CheckFavorites (Please rate this post!)

                T 1 Reply Last reply
                0
                • D David Crow

                  tanarnelinistit wrote:

                  File wincore.cpp Line 883.

                  This is apparently not with VC++ v6. Correct?


                  "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                  "Judge not by the eye but by the heart." - Native American Proverb

                  T Offline
                  T Offline
                  tanarnelinistit
                  wrote on last edited by
                  #15

                  DavidCrow wrote:

                  This is apparently not with VC++ v6. Correct?

                  No, it is with VC++ v6.0. The error is comming from using the str2 CString variable. If I dont use any reference to it there is no problem.

                  D 1 Reply Last reply
                  0
                  • J James R Twine

                    IME, symbol "str2" not found errors in the debugger are due to one of four things:      1: You typed the identifier incorrectly      2: You are in the wrong context      3: You are trying to view a static variable (VC++ 6.0)      4: You have overrun/underrun a buffer    Given that you are also getting additional errors, I would research #4.    Peace!

                    -=- James


                    If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                    Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                    DeleteFXPFiles & CheckFavorites (Please rate this post!)

                    T Offline
                    T Offline
                    tanarnelinistit
                    wrote on last edited by
                    #16

                    James R. Twine wrote:

                    You have overrun/underrun a buffer

                    What do you mean by that? If I don't use multithreads I don't get an error.

                    D 1 Reply Last reply
                    0
                    • T tanarnelinistit

                      Cedric Moonen wrote:

                      Use the callstack to see in which of YOUR function the code crashes. Then put a breakpoint at the begining of this function and step by step to see which instruction makes your program crash.

                      The line that makes my program crash: if (str2=="FFFF00000000028C") m_pSet->m_Nume="Gigi"; else m_pSet->m_Nume="Ionica"; Because that's a line on which I have str2 the variable that is defined and initiated with a value, but which I can't see. -- modified at 8:53 Wednesday 26th July, 2006

                      C Offline
                      C Offline
                      Cedric Moonen
                      wrote on last edited by
                      #17

                      Where does this code come from ?? :confused: Please, when you post something give the complete information. This has absolutely nothing to do with the first code snippet you posted. So how can we guess what the problem is :| ? What is this m_pSet and what is its value ? Is it a valid address ?


                      Cédric Moonen Software developer
                      Charting control

                      1 Reply Last reply
                      0
                      • T tanarnelinistit

                        James R. Twine wrote:

                        You have overrun/underrun a buffer

                        What do you mean by that? If I don't use multithreads I don't get an error.

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #18

                        tanarnelinistit wrote:

                        If I don't use multithreads I don't get an error.

                        Most likely the problem is still present and is simply being masked by some other operation.


                        "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                        "Judge not by the eye but by the heart." - Native American Proverb

                        T 1 Reply Last reply
                        0
                        • T tanarnelinistit

                          DavidCrow wrote:

                          This is apparently not with VC++ v6. Correct?

                          No, it is with VC++ v6.0. The error is comming from using the str2 CString variable. If I dont use any reference to it there is no problem.

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #19

                          tanarnelinistit wrote:

                          No, it is with VC++ v6.0.

                          Line 883 of wincore.cpp does not have any ASSERT() statements. Here are the first few lines of code in the AssertValid() method:

                          #ifdef _DEBUG
                          void CWnd::AssertValid() const
                          {
                          if (m_hWnd == NULL)
                          return; // null (unattached) windows are valid

                          // check for special wnd??? values
                          ASSERT(HWND\_TOP == NULL);       // same as desktop
                          if (m\_hWnd == HWND\_BOTTOM)
                          	ASSERT(this == &CWnd::wndBottom);
                          else if (m\_hWnd == HWND\_TOPMOST)
                          	ASSERT(this == &CWnd::wndTopMost);
                          else if (m\_hWnd == HWND\_NOTOPMOST)
                          	ASSERT(this == &CWnd::wndNoTopMost);
                          else                                             // line 883
                          

                          ...


                          "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                          "Judge not by the eye but by the heart." - Native American Proverb

                          1 Reply Last reply
                          0
                          • D David Crow

                            tanarnelinistit wrote:

                            If I don't use multithreads I don't get an error.

                            Most likely the problem is still present and is simply being masked by some other operation.


                            "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                            "Judge not by the eye but by the heart." - Native American Proverb

                            T Offline
                            T Offline
                            tanarnelinistit
                            wrote on last edited by
                            #20

                            DavidCrow wrote:

                            Most likely the problem is still present and is simply being masked by some other operation.

                            With all respect it can not be posible to have the problem when I don't use multithreads because i use str2 to edit a field in the database and that works fine. I run the program just fine.

                            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