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. Debugging functions placed in the header file...

Debugging functions placed in the header file...

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingquestion
11 Posts 4 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.
  • J Offline
    J Offline
    Joan M
    wrote on last edited by
    #1

    Hello, I need to use template functions, but as it seems that they must be declared and defined in the same file, I've placed them in the header file. After doing this I've noticed two problems: 1. I can't use breakpoints there. 2. I can't see the functions in the class wizard. Any advice? mostly on the first topic, I can live with the second one... but I need to be sure that the pointers passed as parameters are the right ones and I need to be able to debug that functions... Thank you in advance.

    I 1 Reply Last reply
    0
    • J Joan M

      Hello, I need to use template functions, but as it seems that they must be declared and defined in the same file, I've placed them in the header file. After doing this I've noticed two problems: 1. I can't use breakpoints there. 2. I can't see the functions in the class wizard. Any advice? mostly on the first topic, I can live with the second one... but I need to be sure that the pointers passed as parameters are the right ones and I need to be able to debug that functions... Thank you in advance.

      I Offline
      I Offline
      Ian Darling
      wrote on last edited by
      #2

      Having just knocked up a quick test application, I have no problem with setting the breakpoints in the header file. I would guess that maybe the debug information is incorrect for your project (I presume you've tried a full rebuild?) or you have some strange compiler settings that are causing problems, but beyond that I don't see any reason why you can't set breakpoints. Sorry I can't assist you any further than that. -- Ian Darling

      J 1 Reply Last reply
      0
      • I Ian Darling

        Having just knocked up a quick test application, I have no problem with setting the breakpoints in the header file. I would guess that maybe the debug information is incorrect for your project (I presume you've tried a full rebuild?) or you have some strange compiler settings that are causing problems, but beyond that I don't see any reason why you can't set breakpoints. Sorry I can't assist you any further than that. -- Ian Darling

        J Offline
        J Offline
        Joan M
        wrote on last edited by
        #3

        The functions are template based declared in this way:

        template<class T> inline long WriteSomeData(CString csNameOfTheVar, T TemplateParam, int iPort)
        {
        ...
        }

        this declaration is placed as a member of one class. then, I can't place a breakpoint and make it work right. Any idea?

        I J 2 Replies Last reply
        0
        • J Joan M

          The functions are template based declared in this way:

          template<class T> inline long WriteSomeData(CString csNameOfTheVar, T TemplateParam, int iPort)
          {
          ...
          }

          this declaration is placed as a member of one class. then, I can't place a breakpoint and make it work right. Any idea?

          I Offline
          I Offline
          Ian Darling
          wrote on last edited by
          #4

          Nothing looks amiss to me. My first reaction told me it was the inline, but I seriously doubt that's the problem (although I do doubt the usefulness of that inline in this context :-) -- Ian Darling

          J 1 Reply Last reply
          0
          • I Ian Darling

            Nothing looks amiss to me. My first reaction told me it was the inline, but I seriously doubt that's the problem (although I do doubt the usefulness of that inline in this context :-) -- Ian Darling

            J Offline
            J Offline
            Joan M
            wrote on last edited by
            #5

            Hello, Ian Darling wrote: I do doubt the usefulness of that inline in this context Why do you doubt that? :confused: I use that function from some others a lot of times and if I have not misunderstood the inline modifier, it's purpose is to give more velocity to the program by not calling the inline function but adding the inline function code at the place where the inline function call is. Then the pourpose it's clear, isn't it?

            J 1 Reply Last reply
            0
            • J Joan M

              Hello, Ian Darling wrote: I do doubt the usefulness of that inline in this context Why do you doubt that? :confused: I use that function from some others a lot of times and if I have not misunderstood the inline modifier, it's purpose is to give more velocity to the program by not calling the inline function but adding the inline function code at the place where the inline function call is. Then the pourpose it's clear, isn't it?

              J Offline
              J Offline
              Joaquin M Lopez Munoz
              wrote on last edited by
              #6

              If you include the body of a function inside the class definition, then it is the same as if you qualify it with inline. That is,

              class A
              {
              int f(){cout<<1<<;}
              };

              is equivalent to

              class A
              {
              inline int f();
              };
              ...
              int A::f()
              {
              cout<<1;
              }

              Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

              J 1 Reply Last reply
              0
              • J Joan M

                The functions are template based declared in this way:

                template<class T> inline long WriteSomeData(CString csNameOfTheVar, T TemplateParam, int iPort)
                {
                ...
                }

                this declaration is placed as a member of one class. then, I can't place a breakpoint and make it work right. Any idea?

                J Offline
                J Offline
                jarl
                wrote on last edited by
                #7

                inline might be your culprit... -=jarl=-

                J 1 Reply Last reply
                0
                • J jarl

                  inline might be your culprit... -=jarl=-

                  J Offline
                  J Offline
                  Joan M
                  wrote on last edited by
                  #8

                  Hello, First of all thank you for your answer, but after removing the inline, it makes the same: 1. I can't debug the function properly (some times I can debug it (the compiler stops at the breakpoint) and sometimes not and the function is being called (I'm sure about that last part)). :~ 2. The funtions involved (there are various functions placed in the header file) continue without appearing in the ClassView... thank you in advance...

                  1 Reply Last reply
                  0
                  • J Joaquin M Lopez Munoz

                    If you include the body of a function inside the class definition, then it is the same as if you qualify it with inline. That is,

                    class A
                    {
                    int f(){cout<<1<<;}
                    };

                    is equivalent to

                    class A
                    {
                    inline int f();
                    };
                    ...
                    int A::f()
                    {
                    cout<<1;
                    }

                    Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

                    J Offline
                    J Offline
                    Joan M
                    wrote on last edited by
                    #9

                    Hello, First of all thank you for your answer, it has explained me other thing that I didn't know, but after removing the inline, it makes the more or less the same: 1. I can't debug the function properly (some times I can debug it (the compiler stops at the breakpoint) and sometimes not and the function is being called (I'm sure about that last part)). 2. The functions involved (there are various functions placed in the header file) continue without appearing in the ClassView... Could you tell me what's happening? As always, thank you in advance...

                    J 1 Reply Last reply
                    0
                    • J Joan M

                      Hello, First of all thank you for your answer, it has explained me other thing that I didn't know, but after removing the inline, it makes the more or less the same: 1. I can't debug the function properly (some times I can debug it (the compiler stops at the breakpoint) and sometimes not and the function is being called (I'm sure about that last part)). 2. The functions involved (there are various functions placed in the header file) continue without appearing in the ClassView... Could you tell me what's happening? As always, thank you in advance...

                      J Offline
                      J Offline
                      Joaquin M Lopez Munoz
                      wrote on last edited by
                      #10

                      1. I think this is a problem with the debugger and template member functions (I've experienced similar strange things in the past). One way (not tested myself) to make sure the debugger always stops is as follows:

                      template<typename T> void CMyClass::Whatever()
                      {
                      DebuggerStopper();
                      ...
                      }

                      void CMyClass::DebuggerStopper()
                      {
                      } // place the breakpopint here

                      2. The class viewer is crap, I don't know any fix for that. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

                      J 1 Reply Last reply
                      0
                      • J Joaquin M Lopez Munoz

                        1. I think this is a problem with the debugger and template member functions (I've experienced similar strange things in the past). One way (not tested myself) to make sure the debugger always stops is as follows:

                        template<typename T> void CMyClass::Whatever()
                        {
                        DebuggerStopper();
                        ...
                        }

                        void CMyClass::DebuggerStopper()
                        {
                        } // place the breakpopint here

                        2. The class viewer is crap, I don't know any fix for that. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

                        J Offline
                        J Offline
                        Joan M
                        wrote on last edited by
                        #11

                        Well, thank you, I've tested it and it worked OK, I'll be able to detect errors in those functions now. Talking about the other thing... I think I'll be able to live with it... moreover when I'll place that code inside a DLL for further use of it. as always, thank you very much.

                        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