|
SteveRubio wrote: Can anyone tell me what conditions would cause a call to gmtime() to crash the program?
When it's used incorrectly.
Seriously, if you can provide a code snippet, better help can be provided.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Fair enough
static char * yetanotherfunction(){
struct tm *newtime;
time_t ltime;
time(<ime);
newtime = gmtime(<ime);
return (asctime(newtime));
}
The commented line is where the crash occurs. And I've tried moving it around and it is the call to gmtime() that causes problems.
I'm modding a project that I've inherited and this block of code has never caused problems in previous iterations.
|
|
|
|
|
What are you doing with the return value from yetanotherfunction() ? What do you mean by "crash?"
SteveRubio wrote: ...this block of code has never caused problems in previous iterations.
That you know of. A problem may well have existed, but just never surfaced.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
assigning it to a char *, which then gets printed out to the console. At least, that's what's previously happened when the function worked.
And by crash I mean the program stops and windows says that the program has encountered a problem and needs to close. The exception code is 0xc0000005, which I beleive is an access violation, but how the block of code would cause it is beyond me.
As for the last part, fair enough. Change my statement to read "this block of code has never caused program crashes in previous iterations"
|
|
|
|
|
SteveRubio wrote: assigning it to a char *...
Assigning, or copying.
Do you call gmtime() , mktime() , or localtime() elsewhere in your code?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
char * s;
s = yetanotherfunction();
And gmtime is called many other places throughout the code.
I've been looking at some documentation and tinkering with various stuffs, and using _gmtime64() instead of gmtime() doesn't cause the error. The asctime() seems to be the one that fails when I do that.
|
|
|
|
|
SteveRubio wrote: ...using _gmtime64() instead of gmtime() doesn't cause the error.
I would be more inclined to do something like:
char s[32];
strcpy(s, yetanotherfunction()); Because _gmtime64() still shares a common, static structure.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
the strcpy thing will probably be enacted when these shennanigans with the time are figured out.
However, I figured out that rather than just crashing, _gmtime64() simply returns NULL.
|
|
|
|
|
SteveRubio wrote: However, I figured out that rather than just crashing, _gmtime64() simply returns NULL.
So what time value is being passed to it? I assume you've read this:
These functions validate their parameter. If timer is a null pointer, or if the timer value is negative, these functions invoke an invalid parameter handler, as described in Parameter Validation. If execution is allowed to continue, the functions return NULL and set errno to EINVAL.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: So what time value is being passed to it? I assume you've read this:
The result of a call to time(). Either on the time_t itself, or on 0. Either way, the results are strange.
|
|
|
|
|
Hi fellows
Someone tells me that the best way to send an object from a window to another is by serialization. How can I do this? I'm very new in this subject....
Someone have a sugggestion for me?
Thanks a lot
|
|
|
|
|
Alex Cutovoi wrote: ...send an object from a window to another...
What exactly are you wanting to send?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I have 2 windows. In these windows I have a class that I create. This class is exactly the same in both windows. I create the object and I need to send this object from one window to the another window to use it. Actually I'm using unsuccessfully WM_COPYDATA message to send the object. But this is written is MSDN:
"The data being passed must not contain pointers or other references to objects not accessible to the application receiving the data."
Because this, some data in my object are empty.
So, someone suggested me to use serialization, but I'm very very new in this topic...
|
|
|
|
|
Alex Cutovoi wrote: Actually I'm using unsuccessfully WM_COPYDATA message to send the object. But this is written is MSDN:
"The data being passed must not contain pointers or other references to objects not accessible to the application receiving the data."
Because this, some data in my object are empty.
See here and here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks man, it seems to be very useful for me. Thanks
|
|
|
|
|
Hi All,
Which map mode would be support for all type of printers? like compaq,hp officejet,cannon,......IF you know , let me know immediately..
Thankx in Advance
|
|
|
|
|
One of the thread in my application has consumed some windows messages which are aimed to my controls (my own defined control).
Can anyone give me a suggestion what I should do to solve the problem?
|
|
|
|
|
What kind of messages would that be?
User defined such as "WM_USER + X " or "WM_APP + 1 "? If so: read this article[^] by Joe Newcomer.
Hope this helps
--
Roger
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
Thanks Roger. I would read the article.
It is the standard keydown message. I select an item in my list control, then pressed the arrow key up or down, nothing happened in the list control, the selected item has not been changed. I used Spy++ to check and found out that the list control has never recied the key up och down message. The thread which holds the dialog window has recieved the messages, it seems that the thread has consumed the message and never send it to the control. I just wonder why and how I can solve the problem.
BR /Chibi
|
|
|
|
|
What does your thread's message loop look like?
|
|
|
|
|
How can i retrieve GetRecordCount into CString?
i want to retrieve the number of records!
i have : CDatabase_Earth pEarth;
and i want this : pEarth.GetRecordCount();
into this
m_text.SetWindowText(.......);
Bravoone
|
|
|
|
|
Bravoone_2006 wrote: How can i retrieve GetRecordCount into CString?
Use "SELECT COUNT(*) FROM table_name" as your SQL statement.
See here for more.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Why not get it into an int, then use CString::Format() to get it into the CString?
|
|
|
|
|
Where can i find .avi for my program?
i make a CDialog with CAnimateCtrl but i need something like websearch.avi, i need more ... where can i find something like that !?
Bravoone
|
|
|
|
|
Have you tried this?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|