This is the mail archive of the pthreads-win32@sourceware.cygnus.com mailing list for the pthreads-win32 project. See the pthreads-win32 home page for more information.


[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index] [Subject Index] [Author Index] [Thread Index]

GetLastError



Ross,

GetLastError returns the calling threadís last error code value. So, it only
has meaning after an error. The last error code is maintained on a
per-thread basis so multiple threads do not overwrite each otherís
last-error code.

In your test driver, you are calling GetLastError in "non-error" situations
so the return value will represent some error that happened "who knows
when". Appearently on Win98 some MS internal code called an unsupported
function when creating your process. I would not be concerned about this
since they (MS) probably handled that situation internally.

Hope this helps,
Scott

-----Original Message-----
From: Ross Johnson <rpj@ise.canberra.edu.au>
To: POSIX threads on Win32 <pthreads-win32@air.net.au>
Date: Tuesday, February 23, 1999 4:32 AM
Subject: RE: TryEnterCriticalSection on Win98


>>
>> I haven't looked in detail at what GetLastError actually does, ie.
>> whether it's possible for it to return an error from some function
>> called prior to TryEnterCriticalSection. If TryEnter doesn't return
>> an error, then maybe it doesn't reset any previous error info
>> either. I don't know yet.
>>
>
>Ok. I've modified the test code I posted last time (new version
>below) and have come up with something a little odd again. I must
>surely be missing something.
>
>My first test prints the value returned by GetLastError after each
>critical section function call (names abbreviated in the output). I
>also print the value at the very start of main(). I run the same
>.exe on Win98 and WNT, and get different results. First, the output
>from the .exe compiled and linked by Mingw32 on the Win98 box:
>
>[Win98]
>H:\PTHREADS\tests>tryentercs.exe
>Error before: 120
>TryEnterCriticalSection exists: Yes [address: BFFA9031]
>TryEnter: 120
>Init: 120
>Leave: 120
>Delete: 120
>
>
>[WNT]
>C:\PTHREADS\test>tryentercs.exe
>Error before: 0
>TryEnterCriticalSection exists: Yes [address: 77F67518]
>TryEnter: 0
>Init: 0
>Leave: 0
>Delete: 0
>
>