|
Thanks alot, you saved me!!!!
Asura
|
|
|
|
|
Hi
std::vector this notation solved the problem, but now there is another problem that because the Vector class is user-defined, in the header file, it complains that the Vector is undeclared identifier. I tried to include the Vector.h header file in this header file, but it complains that Vector class is redefined. How should I solve this problem then???
// LMRectangle.h file
#include "Vector.h"
class LMRectangle{
public:
...
private:
...
std::vector<Vector> _vertexList;
}
This is the code.
Thanks very much
Asura
Asura
|
|
|
|
|
What's there in Vector.h?
Regards,
Nish
|
|
|
|
|
Vector.h contains the definition of the Vector class which I want it to be stored in the
vector<Vector> _vertexList.
Thanks
Asura
-- modified at 17:57 Tuesday 10th January, 2006
|
|
|
|
|
Okay, you need to #include <vector> as well as your custom "Vector.h". I hope you are doing that.
Now if you are getting an error that Vector is not defined, it probably means, there's something wrong about the way it's defined in Vector.h.
Can you copy/paste the declaration of the class Vector from Vector.h?
Also copy/paste the compiler error message here.
Regards,
Nish
|
|
|
|
|
The Vector.h file is something like:
class Vector{
public:
...
private:
...
};
simple like that.
When I defined the LMRectangle.h file like this:
#include "Vector.h"
class LMRectangle{
public:
...
private:
...
std::vector<Vector> _vertexList;
}
I will get the compiler errors
e:\C++ Projects\Topology\Vector.h(3): error C2011: 'Vector' : 'class' type redefinition
e:\C++ Projects\Topology\LMRectangle.h(7): error C2011: 'LMRectangle' : 'class' type redefinition
Otherwise, if I comment out the first line of the LMRectangle.h file, it will generate the following errors;
e:\C++ Projects\Topology\LMRectangle.h(25): error C2065: 'Vector' : undeclared identifier
e:\C++ Projects\Topology\LMRectangle.h(25): error C2955: 'std::vector' : use of class template requires template argument list
e:\C++ Projects\Topology\LMRectangle.h(7): error C2011: 'LMRectangle' : 'class' type redefinition
e:\C++ Projects\Topology\Vector.h(3): error C2011: 'Vector' : 'class' type redefinition
e:\C++ Projects\Topology\Vector.cpp(30): error C2501: 'Vector' : missing storage-class or type specifiers
Thanks
Asura
|
|
|
|
|
Has "Vector.h" got include guards? The file should look something like this:
<br />
#ifndef __VECTOR_H__<br />
#define __VECTOR_H__<br />
<br />
<br />
#endif // !__VECTOR_H__<br />
The "'class' type redefinition" make we wonder if this is the problem.
Steve
|
|
|
|
|
Why are you creating a header file just to define a vector ? Does this mean this vector is global ? If so, you should declare it in your stdafx, if you have one ( or better yet, don't make it global ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Does anyone recall the name of the professional product that maps out a running process and shows which routines are being hit and how frequently? Its on the tip of my tongue. :/ Googling for "process mapping" isn't very concise.
In any case, what I would ideally like to find ( it probably doesn't exist ) is software which identifies all the function calls in a running process, represents them on the screen as colored squares, and colors them accorded to a weighted value ( how frequently that code is hit ). Every time a function is hit its respective box will highlight green. Each box would show the functions address offset.
Dang I can't remember the name of that software....
|
|
|
|
|
Mithra4096 wrote: Does anyone recall the name of the professional product that maps out a running process and shows which routines are being hit and how frequently?
It's called profiler.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
|
Looks interesting. I see from their reviews page you've used it Any more comments? What was the problem GlowCode found that other tools couldn't?
The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison
Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
G'Day Taka,
I've been using it for quite some time. It is very good at pinpointing where bottlenecks occur. It can also find leaks.
I've not used other any profilers with VC++ code.
The nice thing about Glowcode is you don't need to do anything to your code in order to use it.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
|
|
|
|
|
Mr. Franks,
Thanks for the link, I've downloaded GlowCode but it doesn't seem straight forward.
I've launched my app ( client.exe ), attached to it with GlowCode, and it has identified 0 functions and set 0 hooks.
Does the exe need to be in debug mode? Should I expect this app to work with programs that I personally didn't write or have source for?
Thanks,
- Mithra
|
|
|
|
|
From memory you'll need Symbols. You don't need source, but I can't see much point profiling if you don't. I can't recall whether it works for a Release Build. There are options to load symbols from DLL's. It should all be explained in the help.
I haven't needed to use it for some time, so my memory is a bit vague.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
|
|
|
|
|
My intention was to use the profiler as a reversing tool, but based on what you've said that might not be appropriate.
I'm probably going to have to write a program that performs the functionality I need.
What I want to do is, identify the offset of each individual function within an executable ( or DLL ).
I can manually make this list from disassembler output if I need to.
Once I have this list of function offsets, I'd like to place a hook on every one of them so that execution will detour into some custom code of my own, where the frequency of that specific function call will be tabulated, before resuming normally. With that data in hand, I hope to be able to map out graphically which functions are being hit and at what frequency. This tool would also be useful in displaying frequency relationships between other functions. Case in point, if I was interested in all functions related to outgoing packets ( which I am ), I could identify the function that contained the winsock Send call, track how frequently it gets called over time, and display a list of probable functions based on similar call frequency.
When you've got a threaded program with 26,000 individual functions, backtracing from Send becomes meticulous and unreliable, especially if the code you're trying to find is not explicitly linked. If I can track call frequencies throughout an application, I believe I can narrow down the list of candidates and more quickly find what I'm looking for.
My first thought was to actually write thousands of detours into the running process so that execution would jump out ( into a DLL I injected ), tabulate the call, and resume, but I don't think I will be able to do this practically.
There must be a better method, perhaps setting a hook on each function?
|
|
|
|
|
Thanks. I've only ever used Microsoft's profiler (appalling) and BoundsChecker. BC was OK but having to instrument was a PITA. The IDE integration was nice. It could also run on stuff you didn't have symbols for which is handy if you suspect leaks/errors in a third-party component.
I guess the key question is: is Glowcode worth buying? It seems a shame to spend several hundred dollars on a product that works with VC6 which is now basically obsolete
The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison
Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
Dunno why i am drawing a blank here but here goes...
I have a pointer called buff
Tuff* buf;
Would like to send this data to function, but that function accepts a
NotTuff*
Please help refresh my memory.
|
|
|
|
|
LCI wrote: Dunno why i am drawing a blank here but here goes...
I have a pointer called buff
Tuff* buf;
Would like to send this data to function, but that function accepts a
NotTuff*
How are Tuff and NotTuff polymorphically related?
Regards,
Nish
|
|
|
|
|
I am using the Gdiplus library to display pics on a screen.
One of the calls that i have to make needs an IStream*.
However, i get the sream data from the camera as a cdvoid*. I need to pass the data from the camera to the Gdiplus but passing a cdvoid* to a function that takes an IStream* will not work so i somehow have to cast.
Any thoughts.
|
|
|
|
|
If you are sure that the csvoid* is a pointer to an IStream, go ahead and cast it - you could use dynamic_cast here - though depending on what a csvoid* is, you may have to resort to reinterpret_cast.
Regards,
Nish
|
|
|
|
|
Casting is not going to magically change this object. It's more likely that you need to access the bits of the bitmap and fill them out by traversing the structure you're getting back.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Assuming that the function can handle the conversion:
function( NotTuff *nt )
{
}
...
Tuff *buf;
function((NotTuff *) buf); There's also dynamic_cast if you need it.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
I have a CListBox, not ownerdrawn, and I want its size to be 3 items high, programatically if possible.
Is it possible to the the size of the control to a number of visible elements ?
well, an easier way than calculating that myself, by computing the item height + some padding for the borders.
for example :
int iHeight = m_Listbox.GetItemHeight(0);
int iBoxHeight;
CRect rect;
m_Listbox.GetWindowRect(rect );
iBoxHeight = rect.Height();
CRect rect2;
m_Listbox.GetClientRect( rect2 );
int iClientRectHeight = rect2.Height();
int iTotalBorderHeight = iBoxHeight - iClientRectHeight;
int iSize = 3 * iHeight + iTotalBorderHeight ;
rect.bottom = rect.top + iSize;
m_Listbox.MoveWindow( rect );
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
There isn't some magical SetVisibleItemCount() method or something like that, you'll have to calculate the size as you suggested.
You're on the right track with that algorithm, although that MoveWindow won't work as you expect. It expects coordinates relative to the parent window, and you're giving it coordinates relative to the screen. I'd recommend using SetWindowPos() with the SWP_NOMOVE flags so you only change the size of the window. Other than that it looks good.
And yes, GetItemHeight() will work for an empty list as long as it's not set to LBS_OWNERDRAWVARIABLE style.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|