Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Advanced
Oct 23, 2000

Using errno in DLLs

C++ inherited from C the global variable errno which indicates the success status of a previous operations. An errno value of 0 indicates that the previous operation was successful whereas anon-zero value indicates an error of some sort. To get the actual error message, call the perror() function (declared in stdlib.h). As with all global variables, errno is problematic in multithreaded environments because every thread may change its value. Multithreaded environments often solve this problem by making errno a thread-safe function rather than a variable. When using DLL's, though, errno is even more problematic: the main process and the DLL's it uses have independent instances of errno. Therefore, you can't use errno reliably in applications that use DLL's. Although there are techniques to overcome this problem, my advice is to abandon errno and use exception handling or some other object-oriented technique of reporting and detecting runtime errors.
Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date