jmatyas
asked on
Need help with VC++ 2005 linking error. unresolved external symbol "wchar_t * __cdecl uxdup(char const *)"
Hi. I was given a new task to update a project created in VC++ 2003 to VC++ 2005.
I fixed multiple compile errors, but now I receive linking errors which seem a lot harder to figure out. I got a linking error regarding "LIBCP.LIB", but someone else told me to specify that in "Ignore specific library" in options and that message would go away. I was also told that "LIBCMT.LIB" replaces "LIBCP.LIB", but wasn't told if anything needed to be done for that. Anyways, I now receive the following warning and error messages: (this probably is not enough info to solve the problem, but I need to know how to approach this problem - remember I did not write the code, but need to get it to compile in VC++ 2005. Thanks)
Generating Code...
Compiling resources...
Linking...
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllCanUnloadNow' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllGetClassObject' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllUnregisterServer' should not be assigned an ordinal
Creating library .\..\..\bin\Release/Suite_ CCSPic.lib and object .\..\..\bin\Release/Suite_ CCSPic.exp
T_CCSPICcc.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
LoggedException.obj : error LNK2019: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) referenced in function "public: __thiscall String816::operator char const *(void)" (??BString816@@QAEPBDXZ)
LSC.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
S_CCSPIC.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
Suite_CCSPic.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
LSC.obj : error LNK2019: unresolved external symbol "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) referenced in function "public: __thiscall String816::operator wchar_t const *(void)" (??BString816@@QAEPB_WXZ)
S_CCSPIC.obj : error LNK2001: unresolved external symbol "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z)
T_CCSPICcc.obj : error LNK2001: unresolved external symbol "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z)
.\..\..\bin\Release/Suite_ CCSPic.dll : fatal error LNK1120: 2 unresolved externals
I fixed multiple compile errors, but now I receive linking errors which seem a lot harder to figure out. I got a linking error regarding "LIBCP.LIB", but someone else told me to specify that in "Ignore specific library" in options and that message would go away. I was also told that "LIBCMT.LIB" replaces "LIBCP.LIB", but wasn't told if anything needed to be done for that. Anyways, I now receive the following warning and error messages: (this probably is not enough info to solve the problem, but I need to know how to approach this problem - remember I did not write the code, but need to get it to compile in VC++ 2005. Thanks)
Generating Code...
Compiling resources...
Linking...
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllCanUnloadNow' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllGetClassObject' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllUnregisterServer' should not be assigned an ordinal
Creating library .\..\..\bin\Release/Suite_
T_CCSPICcc.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
LoggedException.obj : error LNK2019: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) referenced in function "public: __thiscall String816::operator char const *(void)" (??BString816@@QAEPBDXZ)
LSC.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
S_CCSPIC.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
Suite_CCSPic.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
LSC.obj : error LNK2019: unresolved external symbol "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) referenced in function "public: __thiscall String816::operator wchar_t const *(void)" (??BString816@@QAEPB_WXZ)
S_CCSPIC.obj : error LNK2001: unresolved external symbol "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z)
T_CCSPICcc.obj : error LNK2001: unresolved external symbol "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z)
.\..\..\bin\Release/Suite_
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your feedback. I am somewhat of a newbie to COM and ATL, but familiar with C++ (at least most of it). Although no linking errors came from "ustring.h", I think it might be my problem file. The file name is ustring.h , but it says ustring.cpp on the first comment line in the code. It also is the only file in my project that has both text strings "uxdup" and "String816" which are both listed in the linker error output.
I don't know how to attach the file as an attachment, so I will paste the whole file as text below. Thanks again for your previous advice. Any further responses are greatly appreciated.
USTRING.H
========================== ======
////////////////////////// ////////// ////////// ////////// ////////// ////////// ///
//
// ustring.cpp - Copyright 1997, Don Box
//
// This file contains overloaded ustrcpy, ustrcat, and ustrlen that
// take either wchar_t or char strings for either argument and map to
// the appropriate CRT routine to do the work. The routines are inlined
// and incur no additional overhead.
//
// size_t ustrlen(const uchar *p);
// uchar *ustrcpy(uchar *p1, const uchar *p2);
// uchar *ustrcat(uchar *p1, const uchar *p2);
//
// where uchar = { wchar_t , char }
//
// This file contains the prototypes for several conversion routines
// that are used by the String816 class for duplicating/converting strings
// on the fly.
//
// uxdup(const char *psz) - returns a new-ed wchar_t string based on psz
// uxdup(const wchar_t *psz) - returns a new-ed char string based on psz
//
// Finally, this file contains two class definitions:
//
// _U - converts const uchar * to const uchar *
// _UNCC - converts const uchar * to uchar * (needed for non-const correct code)
//
// Usage:
/*
void f(const OLECHAR *pwsz, HWND hwnd)
{
TCHAR sz[MAX_PATH];
GUID guid;
ustrcpy(sz, pwsz); // overloads to correct copy/conversion routine
SetWindowText(hwnd, _U(pwsz)); // _U temporarily dups buffer if needed
GetWindowText(hwnd, sz, MAX_PATH);
CLSIDFromString(_UNCC(sz), &guid); // _UNCC needed because api non-const-correct
}
*/
#ifndef _USTR_H
#define _USTR_H
#include <limits.h>
#include <stdio.h>
#include <stdarg.h>
////////////////////////// ////////// ////////// ////////// ////////// ////////// ///
// Begin Extensions
#include "bsd_string.h"
// All of these functions aren't part of Don Box's original ustring library.
inline int uisalpha(int c)
{
return isalpha(c);
}
inline int uisalpha(wint_t c)
{
return iswalpha(c);
}
inline int utoupper(int c)
{
return toupper(c);
}
inline int utoupper(wint_t c)
{
return towupper(c);
}
inline int usprintf(char* pszBuffer, const char* pszFormat, ...)
{
va_list Args;
va_start(Args, pszFormat);
int n = vsprintf(pszBuffer, pszFormat, Args);
va_end(Args);
return n;
}
inline int usprintf(wchar_t* pwszBuffer, const wchar_t* pwszFormat, ...)
{
va_list Args;
va_start(Args, pwszFormat);
int n = vswprintf(pwszBuffer, pwszFormat, Args);
va_end(Args);
return n;
}
inline char* ustrstr(const char* psz1, const char* psz2)
{
return (char *) strstr(psz1, psz2);
}
inline wchar_t* ustrstr(const wchar_t* psz1, const wchar_t* psz2)
{
return (wchar_t *) wcsstr(psz1, psz2);
}
inline char* ustrchr(const char* psz, const int c)
{
return (char *) strchr(psz, c);
}
inline wchar_t* ustrchr(const wchar_t* psz, const int c)
{
return (wchar_t *) wcschr(psz, c);
}
inline char* ustrrchr(const char* psz, const int c)
{
return (char *) strrchr(psz, c);
}
inline wchar_t* ustrrchr(const wchar_t* psz, const int c)
{
return (wchar_t *) wcsrchr(psz, c);
}
inline int ustrcmp(const char* psz1, const char* psz2)
{
return strcmp(psz1, psz2);
}
inline int ustrcmp(const wchar_t* psz1, const wchar_t* psz2)
{
return wcscmp(psz1, psz2);
}
inline int ustrncmp(const char* psz1, const char* psz2, size_t nLength)
{
return strncmp(psz1, psz2, nLength);
}
inline int ustrncmp(const wchar_t* psz1, const wchar_t* psz2, size_t nLength)
{
return wcsncmp(psz1, psz2, nLength);
}
inline int ustricmp(const char* psz1, const char* psz2)
{
return stricmp(psz1, psz2);
}
inline int ustricmp(const wchar_t* psz1, const wchar_t* psz2)
{
return wcsicmp(psz1, psz2);
}
inline char *ustrncpy(char *pszTarget, const wchar_t *pszSrc,
const size_t nLength)
{
return wcstombs(pszTarget, pszSrc, nLength), pszTarget;
}
inline wchar_t *ustrncpy(wchar_t *pszTarget, const wchar_t *pszSrc,
const size_t nLength)
{
return wcsncpy(pszTarget, pszSrc, nLength), pszTarget;
}
inline size_t ustrlcpy(char* pszDst, const char* pszSrc, size_t uSize)
{
return strlcpy(pszDst, pszSrc, uSize);;
}
inline size_t ustrlcpy(char* pszDst, const wchar_t* pwszSrc, size_t uSize)
{
return char_wchar_lcpy(pszDst, pwszSrc, uSize);
}
inline size_t ustrlcpy(wchar_t* pwszDst, const char* pszSrc, size_t uSize)
{
return wchar_char_lcpy(pwszDst, pszSrc, uSize);
}
inline size_t ustrlcpy(wchar_t* pwszDst, const wchar_t* pwszSrc, size_t uSize)
{
return wcslcpy(pwszDst, pwszSrc, uSize);
}
inline size_t ustrlcat(char* pszDst, const char* pszSrc, size_t uSize)
{
return strlcat(pszDst, pszSrc, uSize);
}
inline size_t ustrlcat(char* pszDst, const wchar_t* pwszSrc, size_t uSize)
{
return char_wchar_lcat(pszDst, pwszSrc, uSize);
}
inline size_t ustrlcat(wchar_t* pwszDst, const char* pszSrc, size_t uSize)
{
return wchar_char_lcat(pwszDst, pszSrc, uSize);
}
inline size_t ustrlcat(wchar_t* pwszDst, const wchar_t* pwszSrc, size_t uSize)
{
return wcslcat(pwszDst, pwszSrc, uSize);
}
// End Extensions
////////////////////////// ////////// ////////// ////////// ////////// ////////// ///
inline size_t ustrlen(const wchar_t *psz)
{
return wcslen(psz);
}
inline size_t ustrlen(const char *psz)
{
return strlen(psz);
}
inline char *ustrcpy(char *pszTarget, const wchar_t *pszSrc)
{
return wcstombs(pszTarget, pszSrc, INT_MAX), pszTarget;
}
inline wchar_t *ustrcpy(wchar_t *pszTarget, const wchar_t *pszSrc)
{
return wcscpy(pszTarget, pszSrc), pszTarget;
}
inline char *ustrcpy(char *pszTarget, const char *pszSrc)
{
return strcpy(pszTarget, pszSrc), pszTarget;
}
inline wchar_t *ustrcpy(wchar_t *pszTarget, const char *pszSrc)
{
return mbstowcs(pszTarget, pszSrc, INT_MAX), pszTarget;
}
inline char *ustrncpy(char *pszTarget, const char *pszSrc, size_t nLength)
{
return strncpy(pszTarget, pszSrc, nLength), pszTarget;
}
inline wchar_t *ustrncpy(wchar_t *pszTarget, const char *pszSrc,
size_t nLength)
{
return mbstowcs(pszTarget, pszSrc, nLength), pszTarget;
}
inline char *ustrcat(char *pszTarget, const wchar_t *pszSrc)
{
return wcstombs(pszTarget + ustrlen(pszTarget), pszSrc, INT_MAX), pszTarget;
}
inline wchar_t *ustrcat(wchar_t *pszTarget, const wchar_t *pszSrc)
{
return wcscat(pszTarget, pszSrc);
}
inline char *ustrcat(char *pszTarget, const char *pszSrc)
{
return strcat(pszTarget, pszSrc);
}
inline wchar_t *ustrcat(wchar_t *pszTarget, const char *pszSrc)
{
return mbstowcs(pszTarget + ustrlen(pszTarget), pszSrc, INT_MAX), pszTarget;
}
// these two routines are equivalent to strdup but convert
// instead of just copying
wchar_t *uxdup(const char *psz);
char *uxdup(const wchar_t *pwsz);
// String816 maps const wchar_t * and const char * to
// either const wchar_t * or const char * depending on context
class String816
{
wchar_t *m_pwsz;
char *m_psz;
BOOL m_bIsWide;
public:
String816(const char *psz)
: m_pwsz(0), m_psz((char*)psz), m_bIsWide(FALSE)
{
}
String816(const wchar_t *pwsz)
: m_pwsz((wchar_t*)pwsz), m_psz(0), m_bIsWide(TRUE)
{
}
operator const wchar_t * (void)
{
if (!m_bIsWide && m_pwsz == 0)
m_pwsz = uxdup(m_psz);
return m_pwsz;
}
operator const char * (void)
{
if (m_bIsWide && m_psz == 0)
m_psz = uxdup(m_pwsz);
return m_psz;
}
~String816(void)
{
if (m_bIsWide && m_psz)
free(m_psz);
else if (!m_bIsWide && m_pwsz)
free(m_pwsz);
}
};
// Often it is algorithmically convenient to be able to pass zero to the
// String816 class, and just get zero back from the conversion operators.
// Here's an extension of String816 that does just that.
class String816_SafeOnZero
{
wchar_t *m_pwsz;
char *m_psz;
BOOL m_bIsWide;
public:
String816_SafeOnZero(const char *psz)
: m_pwsz(0), m_psz((char*)psz), m_bIsWide(FALSE)
{
}
String816_SafeOnZero(const wchar_t *pwsz)
: m_pwsz((wchar_t*)pwsz), m_psz(0), m_bIsWide(TRUE)
{
}
operator const wchar_t * (void)
{
if (!m_pwsz && !m_psz)
return 0;
if (!m_bIsWide && m_pwsz == 0)
m_pwsz = uxdup(m_psz);
return m_pwsz;
}
operator const char * (void)
{
if (!m_pwsz && !m_psz)
return 0;
if (m_bIsWide && m_psz == 0)
m_psz = uxdup(m_pwsz);
return m_psz;
}
~String816_SafeOnZero(void )
{
if (m_bIsWide && m_psz)
free(m_psz);
else if (!m_bIsWide && m_pwsz)
free(m_pwsz);
}
};
class Character816
{
wchar_t m_wc;
char m_c;
BOOL m_bIsWide;
public:
Character816(const char c)
: m_wc(0), m_c(c), m_bIsWide(FALSE)
{
}
Character816(const wchar_t wc)
: m_wc(wc), m_c(0), m_bIsWide(TRUE)
{
}
operator const wchar_t (void)
{
#pragma warning(disable : 4172)
if (m_bIsWide)
return m_wc;
return (wchar_t) m_c;
#pragma warning(default : 4172)
}
operator const char (void)
{
#pragma warning(disable : 4172)
if (m_bIsWide)
return (char) m_wc;
return m_c;
#pragma warning(default : 4172)
}
// We have this operator so we can do equality comparisons against other
// characters.
operator const int (void)
{
#pragma warning(disable : 4172)
if (m_bIsWide)
return (int) m_wc;
return (int) m_c;
#pragma warning(default : 4172)
}
};
typedef String816 _U;
typedef String816_SafeOnZero __U;
typedef Character816 _u;
// class _UNCC adds non-const conversion operators to String816
class _UNCC : public String816
{
public:
_UNCC(const char *psz)
: String816(psz)
{
}
_UNCC(const wchar_t *pwsz)
: String816(pwsz)
{
}
operator wchar_t * (void)
{
return (wchar_t*)operator const wchar_t *();
}
operator char * (void)
{
return (char*)operator const char *();
}
};
#endif
I don't know how to attach the file as an attachment, so I will paste the whole file as text below. Thanks again for your previous advice. Any further responses are greatly appreciated.
USTRING.H
==========================
//////////////////////////
//
// ustring.cpp - Copyright 1997, Don Box
//
// This file contains overloaded ustrcpy, ustrcat, and ustrlen that
// take either wchar_t or char strings for either argument and map to
// the appropriate CRT routine to do the work. The routines are inlined
// and incur no additional overhead.
//
// size_t ustrlen(const uchar *p);
// uchar *ustrcpy(uchar *p1, const uchar *p2);
// uchar *ustrcat(uchar *p1, const uchar *p2);
//
// where uchar = { wchar_t , char }
//
// This file contains the prototypes for several conversion routines
// that are used by the String816 class for duplicating/converting strings
// on the fly.
//
// uxdup(const char *psz) - returns a new-ed wchar_t string based on psz
// uxdup(const wchar_t *psz) - returns a new-ed char string based on psz
//
// Finally, this file contains two class definitions:
//
// _U - converts const uchar * to const uchar *
// _UNCC - converts const uchar * to uchar * (needed for non-const correct code)
//
// Usage:
/*
void f(const OLECHAR *pwsz, HWND hwnd)
{
TCHAR sz[MAX_PATH];
GUID guid;
ustrcpy(sz, pwsz); // overloads to correct copy/conversion routine
SetWindowText(hwnd, _U(pwsz)); // _U temporarily dups buffer if needed
GetWindowText(hwnd, sz, MAX_PATH);
CLSIDFromString(_UNCC(sz),
}
*/
#ifndef _USTR_H
#define _USTR_H
#include <limits.h>
#include <stdio.h>
#include <stdarg.h>
//////////////////////////
// Begin Extensions
#include "bsd_string.h"
// All of these functions aren't part of Don Box's original ustring library.
inline int uisalpha(int c)
{
return isalpha(c);
}
inline int uisalpha(wint_t c)
{
return iswalpha(c);
}
inline int utoupper(int c)
{
return toupper(c);
}
inline int utoupper(wint_t c)
{
return towupper(c);
}
inline int usprintf(char* pszBuffer, const char* pszFormat, ...)
{
va_list Args;
va_start(Args, pszFormat);
int n = vsprintf(pszBuffer, pszFormat, Args);
va_end(Args);
return n;
}
inline int usprintf(wchar_t* pwszBuffer, const wchar_t* pwszFormat, ...)
{
va_list Args;
va_start(Args, pwszFormat);
int n = vswprintf(pwszBuffer, pwszFormat, Args);
va_end(Args);
return n;
}
inline char* ustrstr(const char* psz1, const char* psz2)
{
return (char *) strstr(psz1, psz2);
}
inline wchar_t* ustrstr(const wchar_t* psz1, const wchar_t* psz2)
{
return (wchar_t *) wcsstr(psz1, psz2);
}
inline char* ustrchr(const char* psz, const int c)
{
return (char *) strchr(psz, c);
}
inline wchar_t* ustrchr(const wchar_t* psz, const int c)
{
return (wchar_t *) wcschr(psz, c);
}
inline char* ustrrchr(const char* psz, const int c)
{
return (char *) strrchr(psz, c);
}
inline wchar_t* ustrrchr(const wchar_t* psz, const int c)
{
return (wchar_t *) wcsrchr(psz, c);
}
inline int ustrcmp(const char* psz1, const char* psz2)
{
return strcmp(psz1, psz2);
}
inline int ustrcmp(const wchar_t* psz1, const wchar_t* psz2)
{
return wcscmp(psz1, psz2);
}
inline int ustrncmp(const char* psz1, const char* psz2, size_t nLength)
{
return strncmp(psz1, psz2, nLength);
}
inline int ustrncmp(const wchar_t* psz1, const wchar_t* psz2, size_t nLength)
{
return wcsncmp(psz1, psz2, nLength);
}
inline int ustricmp(const char* psz1, const char* psz2)
{
return stricmp(psz1, psz2);
}
inline int ustricmp(const wchar_t* psz1, const wchar_t* psz2)
{
return wcsicmp(psz1, psz2);
}
inline char *ustrncpy(char *pszTarget, const wchar_t *pszSrc,
const size_t nLength)
{
return wcstombs(pszTarget, pszSrc, nLength), pszTarget;
}
inline wchar_t *ustrncpy(wchar_t *pszTarget, const wchar_t *pszSrc,
const size_t nLength)
{
return wcsncpy(pszTarget, pszSrc, nLength), pszTarget;
}
inline size_t ustrlcpy(char* pszDst, const char* pszSrc, size_t uSize)
{
return strlcpy(pszDst, pszSrc, uSize);;
}
inline size_t ustrlcpy(char* pszDst, const wchar_t* pwszSrc, size_t uSize)
{
return char_wchar_lcpy(pszDst, pwszSrc, uSize);
}
inline size_t ustrlcpy(wchar_t* pwszDst, const char* pszSrc, size_t uSize)
{
return wchar_char_lcpy(pwszDst, pszSrc, uSize);
}
inline size_t ustrlcpy(wchar_t* pwszDst, const wchar_t* pwszSrc, size_t uSize)
{
return wcslcpy(pwszDst, pwszSrc, uSize);
}
inline size_t ustrlcat(char* pszDst, const char* pszSrc, size_t uSize)
{
return strlcat(pszDst, pszSrc, uSize);
}
inline size_t ustrlcat(char* pszDst, const wchar_t* pwszSrc, size_t uSize)
{
return char_wchar_lcat(pszDst, pwszSrc, uSize);
}
inline size_t ustrlcat(wchar_t* pwszDst, const char* pszSrc, size_t uSize)
{
return wchar_char_lcat(pwszDst, pszSrc, uSize);
}
inline size_t ustrlcat(wchar_t* pwszDst, const wchar_t* pwszSrc, size_t uSize)
{
return wcslcat(pwszDst, pwszSrc, uSize);
}
// End Extensions
//////////////////////////
inline size_t ustrlen(const wchar_t *psz)
{
return wcslen(psz);
}
inline size_t ustrlen(const char *psz)
{
return strlen(psz);
}
inline char *ustrcpy(char *pszTarget, const wchar_t *pszSrc)
{
return wcstombs(pszTarget, pszSrc, INT_MAX), pszTarget;
}
inline wchar_t *ustrcpy(wchar_t *pszTarget, const wchar_t *pszSrc)
{
return wcscpy(pszTarget, pszSrc), pszTarget;
}
inline char *ustrcpy(char *pszTarget, const char *pszSrc)
{
return strcpy(pszTarget, pszSrc), pszTarget;
}
inline wchar_t *ustrcpy(wchar_t *pszTarget, const char *pszSrc)
{
return mbstowcs(pszTarget, pszSrc, INT_MAX), pszTarget;
}
inline char *ustrncpy(char *pszTarget, const char *pszSrc, size_t nLength)
{
return strncpy(pszTarget, pszSrc, nLength), pszTarget;
}
inline wchar_t *ustrncpy(wchar_t *pszTarget, const char *pszSrc,
size_t nLength)
{
return mbstowcs(pszTarget, pszSrc, nLength), pszTarget;
}
inline char *ustrcat(char *pszTarget, const wchar_t *pszSrc)
{
return wcstombs(pszTarget + ustrlen(pszTarget), pszSrc, INT_MAX), pszTarget;
}
inline wchar_t *ustrcat(wchar_t *pszTarget, const wchar_t *pszSrc)
{
return wcscat(pszTarget, pszSrc);
}
inline char *ustrcat(char *pszTarget, const char *pszSrc)
{
return strcat(pszTarget, pszSrc);
}
inline wchar_t *ustrcat(wchar_t *pszTarget, const char *pszSrc)
{
return mbstowcs(pszTarget + ustrlen(pszTarget), pszSrc, INT_MAX), pszTarget;
}
// these two routines are equivalent to strdup but convert
// instead of just copying
wchar_t *uxdup(const char *psz);
char *uxdup(const wchar_t *pwsz);
// String816 maps const wchar_t * and const char * to
// either const wchar_t * or const char * depending on context
class String816
{
wchar_t *m_pwsz;
char *m_psz;
BOOL m_bIsWide;
public:
String816(const char *psz)
: m_pwsz(0), m_psz((char*)psz), m_bIsWide(FALSE)
{
}
String816(const wchar_t *pwsz)
: m_pwsz((wchar_t*)pwsz), m_psz(0), m_bIsWide(TRUE)
{
}
operator const wchar_t * (void)
{
if (!m_bIsWide && m_pwsz == 0)
m_pwsz = uxdup(m_psz);
return m_pwsz;
}
operator const char * (void)
{
if (m_bIsWide && m_psz == 0)
m_psz = uxdup(m_pwsz);
return m_psz;
}
~String816(void)
{
if (m_bIsWide && m_psz)
free(m_psz);
else if (!m_bIsWide && m_pwsz)
free(m_pwsz);
}
};
// Often it is algorithmically convenient to be able to pass zero to the
// String816 class, and just get zero back from the conversion operators.
// Here's an extension of String816 that does just that.
class String816_SafeOnZero
{
wchar_t *m_pwsz;
char *m_psz;
BOOL m_bIsWide;
public:
String816_SafeOnZero(const
: m_pwsz(0), m_psz((char*)psz), m_bIsWide(FALSE)
{
}
String816_SafeOnZero(const
: m_pwsz((wchar_t*)pwsz), m_psz(0), m_bIsWide(TRUE)
{
}
operator const wchar_t * (void)
{
if (!m_pwsz && !m_psz)
return 0;
if (!m_bIsWide && m_pwsz == 0)
m_pwsz = uxdup(m_psz);
return m_pwsz;
}
operator const char * (void)
{
if (!m_pwsz && !m_psz)
return 0;
if (m_bIsWide && m_psz == 0)
m_psz = uxdup(m_pwsz);
return m_psz;
}
~String816_SafeOnZero(void
{
if (m_bIsWide && m_psz)
free(m_psz);
else if (!m_bIsWide && m_pwsz)
free(m_pwsz);
}
};
class Character816
{
wchar_t m_wc;
char m_c;
BOOL m_bIsWide;
public:
Character816(const char c)
: m_wc(0), m_c(c), m_bIsWide(FALSE)
{
}
Character816(const wchar_t wc)
: m_wc(wc), m_c(0), m_bIsWide(TRUE)
{
}
operator const wchar_t (void)
{
#pragma warning(disable : 4172)
if (m_bIsWide)
return m_wc;
return (wchar_t) m_c;
#pragma warning(default : 4172)
}
operator const char (void)
{
#pragma warning(disable : 4172)
if (m_bIsWide)
return (char) m_wc;
return m_c;
#pragma warning(default : 4172)
}
// We have this operator so we can do equality comparisons against other
// characters.
operator const int (void)
{
#pragma warning(disable : 4172)
if (m_bIsWide)
return (int) m_wc;
return (int) m_c;
#pragma warning(default : 4172)
}
};
typedef String816 _U;
typedef String816_SafeOnZero __U;
typedef Character816 _u;
// class _UNCC adds non-const conversion operators to String816
class _UNCC : public String816
{
public:
_UNCC(const char *psz)
: String816(psz)
{
}
_UNCC(const wchar_t *pwsz)
: String816(pwsz)
{
}
operator wchar_t * (void)
{
return (wchar_t*)operator const wchar_t *();
}
operator char * (void)
{
return (char*)operator const char *();
}
};
#endif
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I also had a separate question on the above code. What exactly does the following code do in the String816 class? The only time I used "operator" was to overload operators (such as +,-,*,++) for the class I was defining.
operator const wchar_t (void)
{
#pragma warning(disable : 4172)
if (m_bIsWide)
return m_wc;
return (wchar_t) m_c;
#pragma warning(default : 4172)
}
operator const char (void)
{
#pragma warning(disable : 4172)
if (m_bIsWide)
return (char) m_wc;
return m_c;
#pragma warning(default : 4172)
}
operator const wchar_t (void)
{
#pragma warning(disable : 4172)
if (m_bIsWide)
return m_wc;
return (wchar_t) m_c;
#pragma warning(default : 4172)
}
operator const char (void)
{
#pragma warning(disable : 4172)
if (m_bIsWide)
return (char) m_wc;
return m_c;
#pragma warning(default : 4172)
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>What exactly does the following code do in the String816 class?
It takes care of implicit and explicit conversions by providing the appropriate operators, so you can just write
String816 str;
//...
cout << (char) str << endl; // explicit
It takes care of implicit and explicit conversions by providing the appropriate operators, so you can just write
String816 str;
//...
cout << (char) str << endl; // explicit
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all the feedback. This really helps me out. I think I know what to do after two final questions.
1) What purpose does "__cdecl" serve in the function definition?
I read something on the internet, but it was not very clear.
2) Which line of code is correct for function uxdup(const char* psz)?
size_t len = strlen(psz) + 1;
OR
int len = strlen(psz);
1) What purpose does "__cdecl" serve in the function definition?
I read something on the internet, but it was not very clear.
2) Which line of code is correct for function uxdup(const char* psz)?
size_t len = strlen(psz) + 1;
OR
int len = strlen(psz);
ASKER
Thanks for the code segment. When I added the above code (re-pasted below) into the bottom of ustring.h, except stdlib.h near top, I get numerous error messages (line numbers included to help):
Is there a "{" missing to match the "}" in line 467?
++++++++++++++++++++++++++ ++++++++++ ++++++++++ ++++++++++
#include <limits.h> // (line 46) always here
#include <stdio.h> // (line 47) always here
#include <stdarg.h> // (line 48) always here
#include <stdlib.h> // (line 49) added today
...
...
#ifdef __cplusplus // (line 443)
extern "C"
#endif // (line 445)
// Code added to define uxdup
wchar_t* uxdup(const char* psz)
{
int len = strlen(psz); // or size_t len = strlen(psz) + 1; // (line 450)
wchar_t* pwsz = new wchar_t[len+1];
mbstowcs(pwsz, psz, len);
return pwsz;
}
// (line 455)
char *uxdup(const wchar_t *pwsz)
{
int len = wstrlen(pwsz);
char* psz = new char[len*2+1];
if (wcstombs(psz, pwsz, len) == (size_t)-1) // (line 460)
*psz=0;
return psz;
}
#ifdef __cplusplus
} // close the brackets (line 467)
#endif
++++++++++++++++++++++++++ ++++++++++ ++++++++++ +++++++
..\include\ustring.h(449) : error C2732: linkage specification contradicts earlier specification for 'uxdup'
..\include\ustring.h(448) : see declaration of 'uxdup'
..\include\ustring.h(458) : error C3861: 'wstrlen': identifier not found
..\include\ustring.h(467) : error C2059: syntax error : '}'
..\include\ustring.h(467) : error C2143: syntax error : missing ';' before '}'
..\include\ustring.h(467) : error C2059: syntax error : '}'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 49) : error C2143: syntax error : missing ';' before '{'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 49) : error C2447: '{' : missing function header (old-style formal list?)
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 57) : error C2084: function 'char *uxdup(const wchar_t *)' already has a body
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(2 75) : see previous definition of 'uxdup'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 58) : error C3861: 'wstrlen': identifier not found
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 67) : error C2059: syntax error : '}'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 67) : error C2143: syntax error : missing ';' before '}'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 67) : error C2059: syntax error : '}'
..\include\pathx.h(142) : error C2143: syntax error : missing ';' before '{'
..\include\pathx.h(142) : error C2447: '{' : missing function header (old-style formal list?)
++++++++++++++++++++++++++ ++++++++++ ++++++++++ ++++++++++
If I comment out these two lines:
wchar_t *uxdup(const char *psz);
char *uxdup(const wchar_t *pwsz);
The compile errors change slightly:
++++++++++++++++++++++++++ ++++++++++ ++++++++++ ++++++++++ +
..\include\ustring.h(299) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(306) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(343) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(352) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(449) : error C2365: 'uxdup' : redefinition; previous definition was 'formerly unknown identifier'
..\include\ustring.h(457) : error C2365: 'uxdup' : redefinition; previous definition was 'formerly unknown identifier'
..\include\ustring.h(458) : error C3861: 'wstrlen': identifier not found
..\include\ustring.h(467) : error C2059: syntax error : '}'
..\include\ustring.h(467) : error C2143: syntax error : missing ';' before '}'
..\include\ustring.h(467) : error C2059: syntax error : '}'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 49) : error C2143: syntax error : missing ';' before '{'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 49) : error C2447: '{' : missing function header (old-style formal list?)
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 57) : error C2365: 'uxdup' : redefinition; previous definition was 'formerly unknown identifier'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 58) : error C3861: 'wstrlen': identifier not found
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 67) : error C2059: syntax error : '}'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 67) : error C2143: syntax error : missing ';' before '}'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 67) : error C2059: syntax error : '}'
..\include\pathx.h(142) : error C2143: syntax error : missing ';' before '{'
..\include\pathx.h(142) : error C2447: '{' : missing function header (old-style formal list?)
++++++++++++++++++++++++++ ++++++++++ ++++++++++ ++++++++++ ++
Hopefully this is something simple to fix to get this thing to compile.
Is there a "{" missing to match the "}" in line 467?
++++++++++++++++++++++++++
#include <limits.h> // (line 46) always here
#include <stdio.h> // (line 47) always here
#include <stdarg.h> // (line 48) always here
#include <stdlib.h> // (line 49) added today
...
...
#ifdef __cplusplus // (line 443)
extern "C"
#endif // (line 445)
// Code added to define uxdup
wchar_t* uxdup(const char* psz)
{
int len = strlen(psz); // or size_t len = strlen(psz) + 1; // (line 450)
wchar_t* pwsz = new wchar_t[len+1];
mbstowcs(pwsz, psz, len);
return pwsz;
}
// (line 455)
char *uxdup(const wchar_t *pwsz)
{
int len = wstrlen(pwsz);
char* psz = new char[len*2+1];
if (wcstombs(psz, pwsz, len) == (size_t)-1) // (line 460)
*psz=0;
return psz;
}
#ifdef __cplusplus
} // close the brackets (line 467)
#endif
++++++++++++++++++++++++++
..\include\ustring.h(449) : error C2732: linkage specification contradicts earlier specification for 'uxdup'
..\include\ustring.h(448) : see declaration of 'uxdup'
..\include\ustring.h(458) : error C3861: 'wstrlen': identifier not found
..\include\ustring.h(467) : error C2059: syntax error : '}'
..\include\ustring.h(467) : error C2143: syntax error : missing ';' before '}'
..\include\ustring.h(467) : error C2059: syntax error : '}'
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
..\include\pathx.h(142) : error C2143: syntax error : missing ';' before '{'
..\include\pathx.h(142) : error C2447: '{' : missing function header (old-style formal list?)
++++++++++++++++++++++++++
If I comment out these two lines:
wchar_t *uxdup(const char *psz);
char *uxdup(const wchar_t *pwsz);
The compile errors change slightly:
++++++++++++++++++++++++++
..\include\ustring.h(299) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(306) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(343) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(352) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(449) : error C2365: 'uxdup' : redefinition; previous definition was 'formerly unknown identifier'
..\include\ustring.h(457) : error C2365: 'uxdup' : redefinition; previous definition was 'formerly unknown identifier'
..\include\ustring.h(458) : error C3861: 'wstrlen': identifier not found
..\include\ustring.h(467) : error C2059: syntax error : '}'
..\include\ustring.h(467) : error C2143: syntax error : missing ';' before '}'
..\include\ustring.h(467) : error C2059: syntax error : '}'
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
..\include\pathx.h(142) : error C2143: syntax error : missing ';' before '{'
..\include\pathx.h(142) : error C2447: '{' : missing function header (old-style formal list?)
++++++++++++++++++++++++++
Hopefully this is something simple to fix to get this thing to compile.
That should be
#ifdef __cplusplus // (line 443)
extern "C" { // <------------- '{' was missing.
#endif // (line 445)
#ifdef __cplusplus // (line 443)
extern "C" { // <------------- '{' was missing.
#endif // (line 445)
>>1) What purpose does "__cdecl" serve in the function definition?
It specifies the calling convention. There are differences how parameters are pushed and popped from the stack when calling a function, and this one specifies the 'C calling convention', which is the default calling convention for C and C++ programs. Because the stack is cleaned up by the caller, it can do vararg functions
>>2) Which line of code is correct for function uxdup(const char* psz)?
size_t len = strlen(psz) + 1;
That's the correct one in any case, since in addition to the actual number of characters, you'll have to add the terminating NULL byte.
It specifies the calling convention. There are differences how parameters are pushed and popped from the stack when calling a function, and this one specifies the 'C calling convention', which is the default calling convention for C and C++ programs. Because the stack is cleaned up by the caller, it can do vararg functions
>>2) Which line of code is correct for function uxdup(const char* psz)?
size_t len = strlen(psz) + 1;
That's the correct one in any case, since in addition to the actual number of characters, you'll have to add the terminating NULL byte.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for clarifying and answering my two questions. You guys really know your stuff, and I can't wait to award you points when this problem gets finished.
I think the problem is almost complete. I put the "{" to match the brackets, and now I receive 8 compile errors. I looked at my C++ book to see what could be wrong, but can't determine the exact problem just by looking. Why is the compiler complaining?
Here's the code along with line numbers and the compile error messages (2 sets of compile errors, with and without lines 275 and 276):
#include <limits.h> // line 46
#include <stdio.h> // line 47
#include <stdarg.h> // line 48
#include <stdlib.h> // line 49
....
wchar_t *uxdup(const char *psz); // line 275
char *uxdup(const wchar_t *pwsz); // line 276
....
....
// Code added to define uxdup
wchar_t* uxdup(const char* psz) // line 448
{
size_t len = strlen(psz) + 1; // line 450
wchar_t* pwsz = new wchar_t[len+1];
mbstowcs(pwsz, psz, len);
return pwsz;
}
char *uxdup(const wchar_t *pwsz) // line 456
{
int len = wstrlen(pwsz); // line 458
char* psz = new char[len*2+1];
if (wcstombs(psz, pwsz, len) == (size_t)-1)
*psz=0;
return psz;
}
..\include\ustring.h(449) : error C2732: linkage specification contradicts earlier specification for 'uxdup'
..\include\ustring.h(448) : see declaration of 'uxdup'
..\include\ustring.h(457) : error C2732: linkage specification contradicts earlier specification for 'uxdup'
..\include\ustring.h(456) : see declaration of 'uxdup'
..\include\ustring.h(458) : error C3861: 'wstrlen': identifier not found
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 49) : error C2084: function 'wchar_t *uxdup(const char *)' already has a body
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(2 75) : see previous definition of 'uxdup'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 49) : error C2732: linkage specification contradicts earlier specification for 'uxdup'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 48) : see declaration of 'uxdup'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 57) : error C2084: function 'char *uxdup(const wchar_t *)' already has a body
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(2 76) : see previous definition of 'uxdup'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 57) : error C2732: linkage specification contradicts earlier specification for 'uxdup'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 56) : see declaration of 'uxdup'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 58) : error C3861: 'wstrlen': identifier not found
++++++++++++++++++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++
If I comment out lines 275 and 276. I get greatly different compile error messages:
..\include\ustring.h(300) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(307) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(344) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(353) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(449) : error C2365: 'uxdup' : redefinition; previous definition was 'formerly unknown identifier'
..\include\ustring.h(457) : error C2365: 'uxdup' : redefinition; previous definition was 'formerly unknown identifier'
..\include\ustring.h(458) : error C3861: 'wstrlen': identifier not found
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 49) : error C2365: 'uxdup' : redefinition; previous definition was 'formerly unknown identifier'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 57) : error C2365: 'uxdup' : redefinition; previous definition was 'formerly unknown identifier'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 58) : error C3861: 'wstrlen': identifier not found
I think the problem is almost complete. I put the "{" to match the brackets, and now I receive 8 compile errors. I looked at my C++ book to see what could be wrong, but can't determine the exact problem just by looking. Why is the compiler complaining?
Here's the code along with line numbers and the compile error messages (2 sets of compile errors, with and without lines 275 and 276):
#include <limits.h> // line 46
#include <stdio.h> // line 47
#include <stdarg.h> // line 48
#include <stdlib.h> // line 49
....
wchar_t *uxdup(const char *psz); // line 275
char *uxdup(const wchar_t *pwsz); // line 276
....
....
// Code added to define uxdup
wchar_t* uxdup(const char* psz) // line 448
{
size_t len = strlen(psz) + 1; // line 450
wchar_t* pwsz = new wchar_t[len+1];
mbstowcs(pwsz, psz, len);
return pwsz;
}
char *uxdup(const wchar_t *pwsz) // line 456
{
int len = wstrlen(pwsz); // line 458
char* psz = new char[len*2+1];
if (wcstombs(psz, pwsz, len) == (size_t)-1)
*psz=0;
return psz;
}
..\include\ustring.h(449) : error C2732: linkage specification contradicts earlier specification for 'uxdup'
..\include\ustring.h(448) : see declaration of 'uxdup'
..\include\ustring.h(457) : error C2732: linkage specification contradicts earlier specification for 'uxdup'
..\include\ustring.h(456) : see declaration of 'uxdup'
..\include\ustring.h(458) : error C3861: 'wstrlen': identifier not found
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
++++++++++++++++++++++++++
If I comment out lines 275 and 276. I get greatly different compile error messages:
..\include\ustring.h(300) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(307) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(344) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(353) : error C3861: 'uxdup': identifier not found
..\include\ustring.h(449) : error C2365: 'uxdup' : redefinition; previous definition was 'formerly unknown identifier'
..\include\ustring.h(457) : error C2365: 'uxdup' : redefinition; previous definition was 'formerly unknown identifier'
..\include\ustring.h(458) : error C3861: 'wstrlen': identifier not found
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
Have you tried to remove the 'extern "C"'?
ASKER
If I remove (comment out) the 'extern "C"' code, I get compile errors, but fewer of them. Only 4 errors instead of 8.
..\include\ustring.h(459) : error C3861: 'wstrlen': identifier not found
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 50) : error C2084: function 'wchar_t *uxdup(const char *)' already has a body
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(2 75) : see previous definition of 'uxdup'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 58) : error C2084: function 'char *uxdup(const wchar_t *)' already has a body
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(2 76) : see previous definition of 'uxdup'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 59) : error C3861: 'wstrlen': identifier not found
..\include\ustring.h(459) : error C3861: 'wstrlen': identifier not found
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
ASKER
I moved the two functions from the bottom to the middle where the "stubs" (now removed) used to be. Now I get only one compile error message.
..\include\ustring.h(289) : error C3861: 'wstrlen': identifier not found
I tried adding "#include <wstring.h>", but that didn't help.
wchar_t is recognized, so I don't know why wstrlen can't be found.
..\include\ustring.h(289) : error C3861: 'wstrlen': identifier not found
I tried adding "#include <wstring.h>", but that didn't help.
wchar_t is recognized, so I don't know why wstrlen can't be found.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Seems I needed too much time to answer ...
ASKER
My system can not find wstring.h , so I did some research on the net.
I replaced "wstrlen" (wstring.h) with "wcslen" (string.h or wchar.h) and now my project compiles, but now I get linking errors again. This time the linking errors are different, saying the subroutines are already defined. I believe this is due to removing the #IFDEF code, but when I have that code in there, I get compiler errors, so I am sorta running in circles.
LSC.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already defined in LoggedException.obj
LSC.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
ParseMsgLine.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already defined in LoggedException.obj
ParseMsgLine.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
RegPathString.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already defined in LoggedException.obj
RegPathString.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
S_CCSPIC.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already defined in LoggedException.obj
S_CCSPIC.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
StdAfx.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already defined in LoggedException.obj
StdAfx.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
Suite_CCSPic.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
T_CCSPICcc.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already defined in LoggedException.obj
T_CCSPICcc.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllCanUnloadNow' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllGetClassObject' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllUnregisterServer' should not be assigned an ordinal
I replaced "wstrlen" (wstring.h) with "wcslen" (string.h or wchar.h) and now my project compiles, but now I get linking errors again. This time the linking errors are different, saying the subroutines are already defined. I believe this is due to removing the #IFDEF code, but when I have that code in there, I get compiler errors, so I am sorta running in circles.
LSC.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already defined in LoggedException.obj
LSC.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
ParseMsgLine.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already defined in LoggedException.obj
ParseMsgLine.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
RegPathString.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already defined in LoggedException.obj
RegPathString.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
S_CCSPIC.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already defined in LoggedException.obj
S_CCSPIC.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
StdAfx.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already defined in LoggedException.obj
StdAfx.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
Suite_CCSPic.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
T_CCSPICcc.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already defined in LoggedException.obj
T_CCSPICcc.obj : error LNK2005: "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) already defined in LoggedException.obj
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllCanUnloadNow' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllGetClassObject' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllUnregisterServer' should not be assigned an ordinal
ASKER
When I have the code broken up like this, I get two compiler error messages:
++++++++++++++++++++++++++ ++++++++++ ++++++++++ +++
wchar_t* uxdup(const char* psz); // near middle
char *uxdup(const wchar_t *pwsz);
wchar_t* uxdup(const char* psz) // at bottom
{
int len = strlen(psz); // or size_t len = strlen(psz) + 1; // (line 450)
wchar_t* pwsz = new wchar_t[len]; // no need for '+1'
mbstowcs(pwsz, psz, len);
return pwsz;
}
char *uxdup(const wchar_t *pwsz)
{
int len = wcslen(pwsz) + 1;
char* psz = new char[len]; // just use 'len' as calculated above, the buffer is large enough
if (wcstombs(psz, pwsz, len) == (size_t)-1) // (line 460)
*psz=0;
return psz;
}
++++++++++++++++++++++++++ ++++++++++ ++++++++++ ++++++++++
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 69) : error C2084: function 'wchar_t *uxdup(const char *)' already has a body
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(2 76) : see previous definition of 'uxdup'
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(4 77) : error C2084: function 'char *uxdup(const wchar_t *)' already has a body
c:\mplab\source\mcdll\pm-s dk-net\src \include\u string.h(2 77) : see previous definition of 'uxdup'
++++++++++++++++++++++++++
wchar_t* uxdup(const char* psz); // near middle
char *uxdup(const wchar_t *pwsz);
wchar_t* uxdup(const char* psz) // at bottom
{
int len = strlen(psz); // or size_t len = strlen(psz) + 1; // (line 450)
wchar_t* pwsz = new wchar_t[len]; // no need for '+1'
mbstowcs(pwsz, psz, len);
return pwsz;
}
char *uxdup(const wchar_t *pwsz)
{
int len = wcslen(pwsz) + 1;
char* psz = new char[len]; // just use 'len' as calculated above, the buffer is large enough
if (wcstombs(psz, pwsz, len) == (size_t)-1) // (line 460)
*psz=0;
return psz;
}
++++++++++++++++++++++++++
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
c:\mplab\source\mcdll\pm-s
Could you add some line number info to the above? 'ustring.h(469)' seems to be 'beyond' that snippet if 'line 460' is still correct.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oh didn't see the comments on wcslen, until now. Thanks.
Is there an advantage to having the code split in two with the function declaration and definition seperate, versus having it defined once in regards to the linking issue? I get a linking issue when I have the subroutine defined in one place, but I get compiler messages listed above when I do try and seperate them.
Is there an advantage to having the code split in two with the function declaration and definition seperate, versus having it defined once in regards to the linking issue? I get a linking issue when I have the subroutine defined in one place, but I get compiler messages listed above when I do try and seperate them.
>>Is there an advantage to having the code split in two with the function declaration and definition seperate
Yes. You don't get the
>>LSC.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already
>>defined in LoggedException.obj
errors any more ;o)
To explain that: When you put the implementation in a header file that is included by multiple .cpp files, the compiler will generate the code in each .cpp file, thus causing the 'multiply' defined errors.
Yes. You don't get the
>>LSC.obj : error LNK2005: "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) already
>>defined in LoggedException.obj
errors any more ;o)
To explain that: When you put the implementation in a header file that is included by multiple .cpp files, the compiler will generate the code in each .cpp file, thus causing the 'multiply' defined errors.
ASKER
Ok. I will put the function bodies in a .cpp file and see how that goes.
ASKER
I created ustring.cpp with the following code in it (and removed the code from ustring.h):
#include "ustring.h"
wchar_t* uxdup(const char* psz)
{
size_t len = strlen(psz) + 1;
wchar_t* pwsz = new wchar_t[len+1];
mbstowcs(pwsz, psz, len);
return pwsz;
}
char *uxdup(const wchar_t *pwsz)
{
int len = wcslen(pwsz);
char* psz = new char[len*2+1];
if (wcstombs(psz, pwsz, len) == (size_t)-1)
*psz=0;
return psz;
}
#include "ustring.h"
wchar_t* uxdup(const char* psz)
{
size_t len = strlen(psz) + 1;
wchar_t* pwsz = new wchar_t[len+1];
mbstowcs(pwsz, psz, len);
return pwsz;
}
char *uxdup(const wchar_t *pwsz)
{
int len = wcslen(pwsz);
char* psz = new char[len*2+1];
if (wcstombs(psz, pwsz, len) == (size_t)-1)
*psz=0;
return psz;
}
ASKER
Now I get the same errors that started this whole tread, but I think that ustring.cpp is not being linked correctly to ustring.h.
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllCanUnloadNow' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllGetClassObject' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllUnregisterServer' should not be assigned an ordinal
Creating library .\..\..\bin\Release/Suite_ CCSPic.lib and object .\..\..\bin\Release/Suite_ CCSPic.exp
T_CCSPICcc.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
LoggedException.obj : error LNK2019: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) referenced in function "public: __thiscall String816::operator char const *(void)" (??BString816@@QAEPBDXZ)
LSC.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
S_CCSPIC.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
Suite_CCSPic.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
LSC.obj : error LNK2019: unresolved external symbol "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) referenced in function "public: __thiscall String816::operator wchar_t const *(void)" (??BString816@@QAEPB_WXZ)
S_CCSPIC.obj : error LNK2001: unresolved external symbol "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z)
T_CCSPICcc.obj : error LNK2001: unresolved external symbol "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z)
.\..\..\bin\Release/Suite_ CCSPic.dll : fatal error LNK1120: 2 unresolved externals
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllCanUnloadNow' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllGetClassObject' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllUnregisterServer' should not be assigned an ordinal
Creating library .\..\..\bin\Release/Suite_
T_CCSPICcc.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
LoggedException.obj : error LNK2019: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z) referenced in function "public: __thiscall String816::operator char const *(void)" (??BString816@@QAEPBDXZ)
LSC.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
S_CCSPIC.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
Suite_CCSPic.obj : error LNK2001: unresolved external symbol "char * __cdecl uxdup(wchar_t const *)" (?uxdup@@YAPADPB_W@Z)
LSC.obj : error LNK2019: unresolved external symbol "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z) referenced in function "public: __thiscall String816::operator wchar_t const *(void)" (??BString816@@QAEPB_WXZ)
S_CCSPIC.obj : error LNK2001: unresolved external symbol "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z)
T_CCSPICcc.obj : error LNK2001: unresolved external symbol "wchar_t * __cdecl uxdup(char const *)" (?uxdup@@YAPA_WPBD@Z)
.\..\..\bin\Release/Suite_
Yup, that looks good - just add that file to your project. BTW, adding the code to any other .cpp file that already is in your project should have worked also.
Have you added the file to your project?
ASKER
Now it is, but I receive this error message:
Compiling...
ustring.cpp
..\include\ustring.cpp(20) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
Creating browse information file...
++++++++++++++++++++++++++ ++++++++++ ++++++++++ ++++++++++
USTRING.CPP
=========================
#include "ustring.h" //line 1
wchar_t* uxdup(const char* psz)
{
size_t len = strlen(psz) + 1; // line 5
wchar_t* pwsz = new wchar_t[len+1];
mbstowcs(pwsz, psz, len);
return pwsz;
}
// line 10
char *uxdup(const wchar_t *pwsz)
{
int len = wcslen(pwsz);
char* psz = new char[len*2+1];
if (wcstombs(psz, pwsz, len) == (size_t)-1)
*psz=0;
return psz;
} // line 19
Compiling...
ustring.cpp
..\include\ustring.cpp(20)
Creating browse information file...
++++++++++++++++++++++++++
USTRING.CPP
=========================
#include "ustring.h" //line 1
wchar_t* uxdup(const char* psz)
{
size_t len = strlen(psz) + 1; // line 5
wchar_t* pwsz = new wchar_t[len+1];
mbstowcs(pwsz, psz, len);
return pwsz;
}
// line 10
char *uxdup(const wchar_t *pwsz)
{
int len = wcslen(pwsz);
char* psz = new char[len*2+1];
if (wcstombs(psz, pwsz, len) == (size_t)-1)
*psz=0;
return psz;
} // line 19
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>>> Suite_CCSPic.def : warning LNK4222: exported symbol 'DllCanUnloadNow'
>>>> should not be assigned an ordinal
You can get rid of that message by editing Suite_CCSPic.def and remove the lines were DllCanUnloadNow, and other Dll* functions were associated to an ordinal number.
Regards, Alex
>>>> should not be assigned an ordinal
You can get rid of that message by editing Suite_CCSPic.def and remove the lines were DllCanUnloadNow, and other Dll* functions were associated to an ordinal number.
Regards, Alex
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oops... I misread the header file the compiler gave an error on.
I thought it only wanted/needed "ustring.h", the same one I already included.
I added #include "stdafx.h" and it fixed the problem.
I now have a project that compiles!!
Now if I can fix the linker warnings:
Linking...
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllCanUnloadNow' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllGetClassObject' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllUnregisterServer' should not be assigned an ordinal
++++++++++++++++++++++++++ ++++++++++ ++++++++++ ++++++
; Suite_CCSPic.def : Declares the module parameters.
========================== ========== ====
LIBRARY "Suite_CCSPic.DLL"
EXPORTS
DllCanUnloadNow @1 PRIVATE
DllGetClassObject @2 PRIVATE
DllRegisterServer @3 PRIVATE
DllUnregisterServer @4 PRIVATE
I thought it only wanted/needed "ustring.h", the same one I already included.
I added #include "stdafx.h" and it fixed the problem.
I now have a project that compiles!!
Now if I can fix the linker warnings:
Linking...
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllCanUnloadNow' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllGetClassObject' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal
.\Suite_CCSPic.def : warning LNK4222: exported symbol 'DllUnregisterServer' should not be assigned an ordinal
++++++++++++++++++++++++++
; Suite_CCSPic.def : Declares the module parameters.
==========================
LIBRARY "Suite_CCSPic.DLL"
EXPORTS
DllCanUnloadNow @1 PRIVATE
DllGetClassObject @2 PRIVATE
DllRegisterServer @3 PRIVATE
DllUnregisterServer @4 PRIVATE
Make that read
EXPORTS
DllCanUnloadNow
DllGetClassObject
DllRegisterServer
DllUnregisterServer
and these should go away also - these exports neither need ordinals nor should they be 'private'.
EXPORTS
DllCanUnloadNow
DllGetClassObject
DllRegisterServer
DllUnregisterServer
and these should go away also - these exports neither need ordinals nor should they be 'private'.
ASKER
What exactly is "Precompiled Header Option"?
Why does ustring.cpp need "stdafx.h"?
I know ustring.cpp needs "ustring.h", but why the other file.
Sorry, I am pretty new to Visual C++, even though I've used C++ in college on Solaris UNIX. I will try "itsmeandnobodyelse" suggestion, when I get some spare time, later in the week, to see if it can be done (learning exercise).
Thanks for your help.
Why does ustring.cpp need "stdafx.h"?
I know ustring.cpp needs "ustring.h", but why the other file.
Sorry, I am pretty new to Visual C++, even though I've used C++ in college on Solaris UNIX. I will try "itsmeandnobodyelse" suggestion, when I get some spare time, later in the week, to see if it can be done (learning exercise).
Thanks for your help.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Back from lunch. Thanks for all the feedback, I understand this a lot better.
I just rebuilt my project and modified only "Suite_CCSPic.def" by removing the ordinals and 'private'. I receive the following warnings:
Linking...
.\Suite_CCSPic.def : warning LNK4104: export of symbol 'DllCanUnloadNow' should be PRIVATE
.\Suite_CCSPic.def : warning LNK4104: export of symbol 'DllGetClassObject' should be PRIVATE
.\Suite_CCSPic.def : warning LNK4104: export of symbol 'DllRegisterServer' should be PRIVATE
.\Suite_CCSPic.def : warning LNK4104: export of symbol 'DllUnregisterServer' should be PRIVATE
++++++++++++++++++++++++++ ++++++++++ ++++++++++ +++++++++
Is this something important, or is it safe to ignore?
If I put private back into the file, I get no errors nor warnings, as follows:
++++++++++++++++++++++++++ ++++++++++ ++++++++++ ++++++++
; Suite_CCSPic.def : Declares the module parameters.
LIBRARY "Suite_CCSPic.DLL"
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
I just rebuilt my project and modified only "Suite_CCSPic.def" by removing the ordinals and 'private'. I receive the following warnings:
Linking...
.\Suite_CCSPic.def : warning LNK4104: export of symbol 'DllCanUnloadNow' should be PRIVATE
.\Suite_CCSPic.def : warning LNK4104: export of symbol 'DllGetClassObject' should be PRIVATE
.\Suite_CCSPic.def : warning LNK4104: export of symbol 'DllRegisterServer' should be PRIVATE
.\Suite_CCSPic.def : warning LNK4104: export of symbol 'DllUnregisterServer' should be PRIVATE
++++++++++++++++++++++++++
Is this something important, or is it safe to ignore?
If I put private back into the file, I get no errors nor warnings, as follows:
++++++++++++++++++++++++++
; Suite_CCSPic.def : Declares the module parameters.
LIBRARY "Suite_CCSPic.DLL"
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
>>Is this something important, or is it safe to ignore?
You *could* ignore it (that wouldn't do any harm), but it seems I was wrong here:
Linker Tools Warning LNK4104
export of symbol "symbol" should be PRIVATE
This warning is emitted when you are building an import library for a DLL and export one of the above functions without specifying it as PRIVATE in the module-definition file. In general these functions are exported for use only by OLE. Placing them in the import library can lead to unusual behavior when a program linked to the library incorrectly makes calls to them.
You *could* ignore it (that wouldn't do any harm), but it seems I was wrong here:
Linker Tools Warning LNK4104
export of symbol "symbol" should be PRIVATE
This warning is emitted when you are building an import library for a DLL and export one of the above functions without specifying it as PRIVATE in the module-definition file. In general these functions are exported for use only by OLE. Placing them in the import library can lead to unusual behavior when a program linked to the library incorrectly makes calls to them.
ASKER
Thanks for explaining that. That sounds like what I am supposed to accomplish. I am now having some problems creating a DLL file from my project; the project compiles and links, but I don't get a DLL file as output like I expected. I will put this question on another thread, and close this call, since the original question has been solved. I really appreciate the help from everybody that responded, esp. jkr and itsmeandnobodyelse. Any feedback on this next question, please post to the new thread, so this one can be closed. Thanks.
------ Build started: Project: Suite_CCSPic, Configuration: Release MinDependency Win32 ------
Linking...
Creating library .\..\..\bin\Release/Suite_ CCSPic.lib and object .\..\..\bin\Release/Suite_ CCSPic.exp
Embedding manifest...
Performing registration
Build log was saved at "file://c:\MPLAB\Source\mc dll\pm-sdk -net\src\S uite_CCSPi c\ReleaseM inDependen cy\BuildLo g.htm"
Suite_CCSPic - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
------ Build started: Project: Suite_CCSPic, Configuration: Release MinDependency Win32 ------
Linking...
Creating library .\..\..\bin\Release/Suite_
Embedding manifest...
Performing registration
Build log was saved at "file://c:\MPLAB\Source\mc
Suite_CCSPic - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Can you post the build log?
Um, I mean - can you post the build log *here* ;o)
>>please post to the new thread, so this one can be closed.
*You* will have to close this Q - please see https://www.experts-exchange.com/Community_Support/help.jsp#hs5 ("Closing Questions")
>>please post to the new thread, so this one can be closed.
*You* will have to close this Q - please see https://www.experts-exchange.com/Community_Support/help.jsp#hs5 ("Closing Questions")
ASKER
Sure, here is the build log (I posted here and also in the new thread):
Build Log
Build started: Project: Suite_CCSPic, Configuration: Release MinDependency|Win32
Command Lines
Creating temporary file "c:\MPLAB\Source\mcdll\pm- sdk-net\sr c\Suite_CC SPic\Relea seMinDepen dency\RSP0 0000D44419 80.rsp" with contents
[
/OUT:".\..\..\bin\Release/ Suite_CCSP ic.dll" /INCREMENTAL:NO /LIBPATH:"..\include" /DLL /MANIFEST /MANIFESTFILE:".\ReleaseMi nDependenc y\Suite_CC SPic.dll.i ntermediat e.manifest " /NODEFAULTLIB:"libc.lib" /NODEFAULTLIB:"libcd.lib" /NODEFAULTLIB:"libcp.lib" /DEF:".\Suite_CCSPic.def" /PDB:".\..\..\bin\Release/ Suite_CCSP ic.pdb" /SUBSYSTEM:WINDOWS /IMPLIB:".\..\..\bin\Relea se/Suite_C CSPic.lib" /MACHINE:X86 htmlhelp.lib version.lib ModuleInfo.lib shell32.lib gdi32.lib ustring.lib bsd_string.lib
".\ReleaseMinDependency\Lo ggedExcept ion.obj"
".\ReleaseMinDependency\LS C.obj"
".\ReleaseMinDependency\Pa rseMsgLine .obj"
".\ReleaseMinDependency\Re gPathStrin g.obj"
".\ReleaseMinDependency\S_ CCSPIC.obj "
".\ReleaseMinDependency\S_ MenuProxy2 .obj"
".\ReleaseMinDependency\S_ Service.ob j"
".\ReleaseMinDependency\SA _CCSPIC.ob j"
".\ReleaseMinDependency\St dAfx.obj"
".\ReleaseMinDependency\Su ite_CCSPic .obj"
".\ReleaseMinDependency\Su ite_CCSPic .res"
".\ReleaseMinDependency\T_ CCSPICcc.o bj"
".\ReleaseMinDependency\TA _CCSPICcc. obj"
".\ReleaseMinDependency\TA _CCSPICccP age.obj"
".\ReleaseMinDependency\TA _CCSPICPag e.obj"
".\ReleaseMinDependency\Tr ans.obj"
".\ReleaseMinDependency\Tr ansDesc.ob j"
".\ReleaseMinDependency\Tr ansEng.obj "
".\ReleaseMinDependency\Tr ansSem.obj "
".\ReleaseMinDependency\us tring1.obj "
]
Creating command line "link.exe @"c:\MPLAB\Source\mcdll\pm -sdk-net\s rc\Suite_C CSPic\Rele aseMinDepe ndency\RSP 00000D4441 980.rsp" /NOLOGO /ERRORREPORT:PROMPT"
Creating temporary file "c:\MPLAB\Source\mcdll\pm- sdk-net\sr c\Suite_CC SPic\Relea seMinDepen dency\RSP0 0000E44419 80.rsp" with contents
[
/outputresource:"..\..\bin \Release\S uite_CCSPi c.dll;#2" /manifest
".\ReleaseMinDependency\Su ite_CCSPic .dll.inter mediate.ma nifest"
]
Creating command line "mt.exe @"c:\MPLAB\Source\mcdll\pm -sdk-net\s rc\Suite_C CSPic\Rele aseMinDepe ndency\RSP 00000E4441 980.rsp" /nologo"
Creating temporary file "c:\MPLAB\Source\mcdll\pm- sdk-net\sr c\Suite_CC SPic\Relea seMinDepen dency\BAT0 0000F44419 80.bat" with contents
[
@echo Manifest resource last updated at %TIME% on %DATE% > ".\ReleaseMinDependency\mt .dep"
]
Creating command line """c:\MPLAB\Source\mcdll\p m-sdk-net\ src\Suite_ CCSPic\Rel easeMinDep endency\BA T00000F444 1980.bat"" "
Creating temporary file "c:\MPLAB\Source\mcdll\pm- sdk-net\sr c\Suite_CC SPic\Relea seMinDepen dency\BAT0 0001044419 80.bat" with contents
[
@echo off
regsvr32 /s /c "c:\MPLAB\Source\mcdll\pm- sdk-net\bi n\Release\ Suite_CCSP ic.dll"
echo regsvr32 exec. time > ".\..\..\bin\Release\regsv r32.trg"
if errorlevel 1 goto VCReportError
goto VCEnd
:VCReportError
echo Project : error PRJ0019: A tool returned an error code from "Performing registration"
exit 1
:VCEnd
]
Creating command line """c:\MPLAB\Source\mcdll\p m-sdk-net\ src\Suite_ CCSPic\Rel easeMinDep endency\BA T000010444 1980.bat"" "
Output Window
Linking...
Creating library .\..\..\bin\Release/Suite_ CCSPic.lib and object .\..\..\bin\Release/Suite_ CCSPic.exp
Embedding manifest...
Performing registration
Results
Build log was saved at "file://c:\MPLAB\Source\mc dll\pm-sdk -net\src\S uite_CCSPi c\ReleaseM inDependen cy\BuildLo g.htm"
Suite_CCSPic - 0 error(s), 0 warning(s)
Build Log
Build started: Project: Suite_CCSPic, Configuration: Release MinDependency|Win32
Command Lines
Creating temporary file "c:\MPLAB\Source\mcdll\pm-
[
/OUT:".\..\..\bin\Release/
".\ReleaseMinDependency\Lo
".\ReleaseMinDependency\LS
".\ReleaseMinDependency\Pa
".\ReleaseMinDependency\Re
".\ReleaseMinDependency\S_
".\ReleaseMinDependency\S_
".\ReleaseMinDependency\S_
".\ReleaseMinDependency\SA
".\ReleaseMinDependency\St
".\ReleaseMinDependency\Su
".\ReleaseMinDependency\Su
".\ReleaseMinDependency\T_
".\ReleaseMinDependency\TA
".\ReleaseMinDependency\TA
".\ReleaseMinDependency\TA
".\ReleaseMinDependency\Tr
".\ReleaseMinDependency\Tr
".\ReleaseMinDependency\Tr
".\ReleaseMinDependency\Tr
".\ReleaseMinDependency\us
]
Creating command line "link.exe @"c:\MPLAB\Source\mcdll\pm
Creating temporary file "c:\MPLAB\Source\mcdll\pm-
[
/outputresource:"..\..\bin
".\ReleaseMinDependency\Su
]
Creating command line "mt.exe @"c:\MPLAB\Source\mcdll\pm
Creating temporary file "c:\MPLAB\Source\mcdll\pm-
[
@echo Manifest resource last updated at %TIME% on %DATE% > ".\ReleaseMinDependency\mt
]
Creating command line """c:\MPLAB\Source\mcdll\p
Creating temporary file "c:\MPLAB\Source\mcdll\pm-
[
@echo off
regsvr32 /s /c "c:\MPLAB\Source\mcdll\pm-
echo regsvr32 exec. time > ".\..\..\bin\Release\regsv
if errorlevel 1 goto VCReportError
goto VCEnd
:VCReportError
echo Project : error PRJ0019: A tool returned an error code from "Performing registration"
exit 1
:VCEnd
]
Creating command line """c:\MPLAB\Source\mcdll\p
Output Window
Linking...
Creating library .\..\..\bin\Release/Suite_
Embedding manifest...
Performing registration
Results
Build log was saved at "file://c:\MPLAB\Source\mc
Suite_CCSPic - 0 error(s), 0 warning(s)
Good, jkr. I didn't find any valuable.