Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- C Ambiguous call to overloaded function
- inline void MySafeStrncpy(char *strDest,size_t maxsize,const char *strSource)
- {
- if(maxsize)
- {
- maxsize--;
- strncpy(strDest,strSource,maxsize);
- strDest[maxsize]=0;
- }
- }
- inline void MySafeStrncpy(char *strDest,size_t maxDestSize,
- const char *strSource, size_t maxSourceSize)
- {
- size_t minSize=(maxDestSize<maxSourceSize) ? maxDestSize:maxSourceSize;
- MySafeStrncpy(strDest,minSize,strSource);
- }
- template <size_t size>
- void MySafeStrncpy(char (&strDest)[size],const char *strSource)
- {
- MySafeStrncpy(strDest,size,strSource);
- }
- template <size_t sizeDest,size_t sizeSource>
- void MySafeStrncpy(char (&strDest)[sizeDest],
- const char (&strSource)[sizeSource])
- {
- MySafeStrncpy(strDest,sizeDest,strSource,sizeSource);
- }
- template <size_t sizeSource>
- void MySafeStrncpy(char *strDest,size_t maxDestSize,
- const char (&strSource)[sizeSource])
- {
- MySafeStrncpy(strDest,maxDestSize,strSource,sizeSource);
- }
- char threadname[16];
- MySafeStrncpy(threadname,"MainThread");
- error C2668: 'MySafeStrncpy' : ambiguous call to overloaded function
- > could be 'void MySafeStrncpy<16,11>(char (&)[16],const char (&)[11])'
- > or 'void MySafeStrncpy<16>(char (&)[16],const char *)'
- > while trying to match the argument list '(char [16], const char [11])'
- template <size_t size>
- void MySafeStrncpy(char (&strDest)[size],const char *strSource)
- template <size_t size, class T>
- void MySafeStrncpy(char (&strDest)[size], T strSource)
- MySafeStrncpy(threadname,"MainThread");
- MySafeStrncpy(threadname, sizeof threadname, "MainThread");
Add Comment
Please, Sign In to add comment