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