|
Hi all,
I am wondering if we can get sourcecode information when an exception occurs. I understand we need debug symbols to get actual source file and line number, but is there a way I can get a unique identifiers that describe the source file and linenumbers where the crash occured - somethng from the dissembly of the callstack? Microsoft must be doing this internally, but is this information available for external developers? Your help is very much appreciated.
Nachiket
|
|
|
|
|
Well, unfortunately if your using Visual Studio 2005 or higher then you need to parse the PDB to obtain the line number in a Release build. Unless you want to add __LINE__ macros[^] all over your code...
This may help:
Retrieving Symbol Information by Address[^]
If you are using Visual Studio 2003 or below you can use the /MAPINFO:LINES linker option. This will create a MAP file which contains symbolic names, address offsets and even line numbers at the bottom. When an exception occurs all you needed to do was walk the list of line numbers and compare the address of the exception to the ones in the list.
I dont really know why they removed the /MAPINFO:LINES option but I suspect it has something to do with VS2005 optimizations.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks David. That was really helpful information.
|
|
|
|
|
Hello. I'm writing a program using M$ Visual C++. Is there a simple API for getting the file size? Something like GetFileSize? I'm trying to read out bytes from a binary file, and I think it's prematurely reading out an EOF character. So, I need to query the filesize from the OS. Thanks.
|
|
|
|
|
pcpro178 wrote: Is there a simple API for getting the file size? Something like GetFileSize?
You mean something like GetFileSize()[^]? Yeah, there is.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Well, yes, but GetFileSize requires a variable of type HANDLE to be passed to it. I have a FILE variable instantiated, but how do I go from one to the other?
|
|
|
|
|
If you insist on the FILE pointer, you can do this:
fseek(file, 0, SEEK_END);
filesize = ftell(file);
fseek(file, 0, SEEK_SET);
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
There are multiple ways including the following simplified code (will not compile):
FILE* pFile = fopen();
if (pFile)
{
int fileNum = _fileno(pFile)
HANDLE hFile = (HANDLE) _get_osfhandle(fileNum);
GetFileSize(hFile);
}
|
|
|
|
|
Thanks! This was a huge help!
|
|
|
|
|
I need to draw an image that is able to zoom in many times, the image in question is of a city. Currently I am drawing the image using a .bmp file, the problem is when I zoom in too much I get the blocky, pixelation associated with .bmp files. I would like some suggestions, ideas, tutorials, etc. on what I should do to keep the fidelity of the image a any zoom level. Should I use a paging scheme for the drawing, is it possible to draw some vector based image or I there something else I should be looking into? General info: drawing using MFC GDI functions, the current image size is around 100 mb. Thanks in advance for any guidance.
|
|
|
|
|
I suggest you try PhotoShop first to resize your image smaller for multiple times.
If PS can not do it well, you should give up.
Or you may need to use jpg format to zoom in your image - zoom in with jpg is better than bitmap format.
|
|
|
|
|
includeh10 wrote: zoom in with jpg is better than bitmap format
Really, have you tried it?
It's the same, except now you have jpg artifacts all over the place.
|
|
|
|
|
includeh10 wrote: zoom in with jpg is better than bitmap format
neither format has any influence on the ability to zoom on the final image. after decoding either, you get an array of pixels - and pixels are pixels, regardless of where they came from.
|
|
|
|
|
tealomp wrote: the problem is when I zoom in too much I get the blocky, pixelation associated with .bmp files
that's not BMP files, that's just what you get when you zoom in on a raster-based image. at some point, there's just not enough information in the original file to zoom in any further - there's no way to interpolate any more data between the source pixels and you end up magnifying the source pixels themselves. this is true regardless of the source of the image or the algorithm used to zoom (though some algorithms are better than others).
tealomp wrote: what I should do to keep the fidelity of the image a any zoom level
there is no way to do such a thing with a raster-based image.
on the other hand, vector-based images can scale to any size. or, you could do something like MrSID, which is an image format that blends images of multiple resolutions to allow for smooth zooming over a large range. it's used primarily for satellite data.
|
|
|
|
|
when i programming this night, i come up against some difficulties.
i use c-free 4.1
let's see the program first:
=========================================================
#include<iostream.h>
#define PI 3.141529
void main()
{
float radius;
float area = 2*radius*PI;
cout << "Plz input the radius:\n";
cin >> radius;
cout << "The area is " << area << endl;
}
=========================================================
so, very easy right! but, something happens:
i input 40
when i debug first time , the window shows the area is -56116.4
when i debug second time, it shows -7.19607e-35
oh!!my god!!
whats happen?
as i know, the right count is 251.32232
someone help me plz!
|
|
|
|
|
#include <iostream>
using namespace std;
#define PI 3.141529
void main()
{
float radius;
cout << "Plz input the radius:\n";
cin >> radius;
float area = 2*radius*PI;
cout << "The area is " << area << endl;
}
Best wishes
Nuri
|
|
|
|
|
Why do you calculate the area before asking the radius to the user ? Of course it doesn't work because your radius variable is not initialized properly...
|
|
|
|
|
In this universe, the area of circle is calculated r^2*pi and not 2*r*pi .
I can't believe nobody screamed yet
|
|
|
|
|
As long as radius is 2, what's the big deal?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Smartass
|
|
|
|
|
Oh yes, the other error was so obvious that I totally missed that
|
|
|
|
|
I have a printer driver that implements various Drv... functions, like DrvStartDoc, DrvBitBlt, etc. I want it to implement DrvLoadFontFile also, but that function never gets called, even when I print files from Adobe PDF Reader where I know have embedded fonts. What do I need to so DrvLoadFontFile gets called?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hello,
I used GetCaretPos() to get the caret/cursor position in the CRichEditCtrl box but I am not getting the proper position.
When the cursor is placed before the first character in the text and I
write the following code
CPoint Charpoint;
GetCaretPos(Charpoint);
The answer is
Charpoint.x = 8 Charpoint.y=0;
whereas Charpoint.x = 1 should be the answer
Which other function should I use.
Regards,
Pritha
|
|
|
|
|
Well, the Caret and the Cursor are two different things. The cursor is moved with the mouse, and the Caret is changed by (eg) the edit control. It will typically be a flashing vertical line. Where is *it*?
You may have just clicked in the control and given it the focus. You'd need to click again to get the caret where the mouse is.
Lastly, if it's before the 1st char, I'd expect x = 0 myself. But the reply is in pixels, not chars, so maybe there's an 8 pixel wide margin?
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
prithaa wrote: whereas Charpoint.x = 1 should be the answer
Nope. You should read the documentation[^] before using a function you don't know. As specified in the doc, the function returns the client coordinates of the caret pos (so, a "screen" position, not a character index).
You have to use the CharFromPos[^] function to convert the position into a character index.
|
|
|
|