简体   繁体   中英

error C2039: 'memchr' : is not a member of '`global namespace''

It has been quite a while since I am getting this error in the standard <cstring> header file for no apparent reason. A google search brought up many answers but none of them worked.

Ok I fixed it myself. It was a stupid mistake! I have a file called "String.h" in a library project which is being picked up by the <cstring> header. Probably because I have added the path to <String.h> as an additional include directory in my test project (where I am getting this error.) Hope this helps someone.

Your compiler may be (correctly) placing the memchr function in the C++ std namespace. Try prefixing memchr call with std:: and if that fails, post the code that causes the problem.

Preprocessor defines are pretty handy when you want to avoid this sort of mistake.

//whatev.h
#ifndef WHATEV
#define WHATEV

// your code here

#endif

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM