1. Reading errno from msvcrt.dll

How do I get the value of errno and _doserrno from msvcrt.dll? I'm using
define_c_var()(using "_errno" and "__doserrno") to get the addresses. I then use
peek4s() to see what their values are. No matter what, I am getting 28075240 and
28071656 decimal respectively. These are invalid error numbers (I've verified
that by using strerror).

I know I am getting the error that I am intentionally causing because I can use
perror to print the error message.

I might not need this, but I would like to rely on more information than just -1
returned from an IO function.

Anyone have experience in this?

new topic     » topic index » view message » categorize

2. Re: Reading errno from msvcrt.dll

It's been a while, but isn't "_errno" a function, not a value?  I seem to
remember having to figure that out once long ago...

Jonas Temple
http://www.yhti.net/~jktemple

new topic     » goto parent     » topic index » view message » categorize

3. Re: Reading errno from msvcrt.dll

Jonas Temple wrote:
> 
> It's been a while, but isn't "_errno" a function, not a value?  I seem to
> remember
> having to figure that out once long ago...
> 
> Jonas Temple
> <a href="http://www.yhti.net/~jktemple">http://www.yhti.net/~jktemple</a>

I've been referring to both the glibc and the msvcrt documentation and they both
say that errno is declared as an external int.

--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
j.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Reading errno from msvcrt.dll

Jason Gade wrote:
> I've been referring to both the glibc and the msvcrt documentation and they
> both say that errno is declared as an external int. 

I don't know if this is relevant:

http://support.microsoft.com/default.aspx?scid=kb;en-us;94248

See section 4, it is about accessing errno in MSVCRT from a another 
C Runtime Library not doing what you expect.

I can't see that being the issue though because you are referencing the 
variable in MSVCRT presumably.

Gary

new topic     » goto parent     » topic index » view message » categorize

5. Re: Reading errno from msvcrt.dll

ags wrote:
> 
> Jason Gade wrote:
> > I've been referring to both the glibc and the msvcrt documentation and they
> > both say that errno is declared as an external int. 
> 
> I don't know if this is relevant:
> 
> <a
> href="http://support.microsoft.com/default.aspx?scid=kb">http://support.microsoft.com/default.aspx?scid=kb</a>;en-us;94248
> 
> See section 4, it is about accessing errno in MSVCRT from a another 
> C Runtime Library not doing what you expect.
> 
> I can't see that being the issue though because you are referencing the 
> variable in MSVCRT presumably.
> 
> Gary

Thanks for the link. It looks like it might be related but I didn't get a clear
solution from it. The thing that gets me is that the perror() function works, but
I would like to get errno so I can pass it back to the user of the library.

I may have to try this on Linux to see what result I get.

--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
j.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu