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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


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

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


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