Quantcast
Channel: EngineerZone: Message List
Viewing all articles
Browse latest Browse all 28044

Re: toupper is not thread safe.

$
0
0

First of all, apologies for the delay in replying to this.

 

Thanks for reporting this issue, you are correct the way the in-line implementation (provided by ctype.h) uses a global variable which is not thread safe. This issue only applies to the in-line implementation, and the out-of-line (library call) is safe to use in a multi-threaded environment.

 

To force use of the out-of-line copy, you just need to #undef the appropriate functions after including  ctype.h, for example:

 

#include <ctype.h>
#undef toupper
#undef tolower

 

Which will do the equivalent of your own function.

 

Regards,

Murray


Viewing all articles
Browse latest Browse all 28044

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>