Re: Help please



hi Mr Asm,
i would like to provide "CSimString" class code because the settings
Properties -> General -> Character set and set it to "Use Multi-Byte
Character Set", and Rebuild All doesn't work for my problem.
*********my code written based on UNICODE only************
**************CSimString.h code*************

class CSimString
{
public:
..............
// Constructors

CSimString();

// Construct with existing C string
CSimString(LPSTR szString);
CSimString(LPCSTR szString);

CSimString(LPCTSTR lpszString);

CSimString(LPCTSTR lpch, int nLength);

// Construct with existing CSimString reference
CSimString(const CSimString& strOriginal);

// Construct with existing CSimString pointer
CSimString(CSimString* pstrOriginal);

// Construct by loading string from resouce
// If hResource is NULL, GetResourceHandle() will be used
CSimString(UINT nStringID, bool bGenericStringTable = false);
**************************************************
*******************CSimString.cpp****************
CSimString::CSimString() : m_lpszString(NULL)
{
Init_();

Alloc(0);
}

CSimString::CSimString(LPCTSTR lpszString) : m_lpszString(NULL)
{
Init_();

AllocNew(lpszString);
}

CSimString::CSimString(const CSimString& strOriginal) : m_lpszString(NULL)
{
Init_();

AllocNew((LPCTSTR)strOriginal);
}

CSimString::CSimString(CSimString* pstrOriginal) : m_lpszString(NULL)
{
Init_();

if (pstrOriginal)
{
AllocNew((LPCTSTR)*pstrOriginal);
}
else
{
AllocNew(TEXT(""));
}
}

CSimString::CSimString(UINT nStringID, bool bGenericStringTable) :
m_lpszString(NULL)
{
Init_();

LoadString(nStringID, bGenericStringTable);
}
***********************************************************
-karimulla

"MrAsm" wrote:

On Fri, 1 Jun 2007 00:10:01 -0700, karim
<karim@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

The Rebuild All has not solved my problem.If i comment
one of those two funtion declaration and defination.i am ok
compiler/linker.problem is when i used it with same namespace, class and same
argument list.

Hi,

I agree with Tom that first step is project clean and rebuild all.

If it does not work, then it could be interesting to see some of your
code...

now i changed the code in my cpp like
[...]

You changed your code in a correct way.

Now you have to remove the other errors.

now here is my problem.there is a lot errors in my project like below

====================================

Error 56 error LNK2005: "public: __thiscall std::allocator<unsigned
short>::allocator<unsigned short>(void)" (??0?$allocator@G@std@@QAE@XZ)
already defined in ReadMixTables.obj msvcprt.lib


Error 60 error LNK2005: "class _variant_t vtMissing"
(?vtMissing@@3V_variant_t@@A) already defined in comsuppw.lib(comutil.obj)
comsupp.lib


Error 61 error LNK2001: unresolved external symbol "public: __thiscall
CSimString::CSimString(unsigned short const *)" (??0CSimString@@QAE@PBG@Z)
simwfp.lib

Error #3: The linker fails to find things.
It would be interesting to see code of your class CSimString.

Is this a string class? Do you have the implementation of the
constructor with the 'unsigned short const *' parameter?
Would the real prototype be: 'const unsigned short *'?
(In this case, it seems to me that you are initializing this class
with a Unicode string, because Unicode characters are 'unsigned
short's .)

Consider that VS2005 strings are Unicode by default, while VS6 strings
are Ansi by default (so maybe you wrote code for Ansi strings in VS6
and now are having problem with Unicode strings under VS2005).

Just to test, you might want to disable Unicode build in VS2005
(disable "Use Unicode libraries" in MFC Application Wizard, or modify
the Properties -> General -> Character set and set it to "Use
Multi-Byte Character Set"), and try a rebuild all.

You might see this link by Mihai (MVP), but these pages show how to
enable Unicode, while, for this test, you have to *disable* Unicode:

http://www.mihai-nita.net/article.php?artID=20060723a

If, after disabling Unicode, you have no build errors, then it means
that the problems are related to uncorrect (Unicode unaware) string
management.

Now, I strongly recommend that you do use Unicode (note that Windows
uses Unicode internally, so even if you use Ansi strings, those
strings get converted to Unicode when passed to the Windows API - and
this is less efficient than having native Unicode strings ready in the
application.)
So, if the problem is wrong string management in your code, you should
fix it.

Give us some feed-back and we'll try to help.

MrAsm


.



Relevant Pages

  • Re: How to check variables for uniqueness ?
    ... characters is the sequence SS. ... is simply capitalizing strings. ... The fact that case mapping in English /is/ simple is neither here not ... That is a fair criticism of the Unicode position. ...
    (comp.lang.java.programmer)
  • Re: Dangerous behavior of CString
    ... If I'm reading a data file or serial port or something, if the raw data are multibyte but the compilation is Unicode or vice-versa, then sometimes the converting constructors in CString are convenient. ... I did not actually write code like this; in fact I was pretty careful always to use the _T macro with any literal strings. ... But it does the conversion using the current 8-bit code page, which is not what I want. ...
    (microsoft.public.vc.mfc)
  • Re: passing a string to a dll
    ... bool DLLRect::PullWhisker ... The interface for the DLL exported function could be like so: ... based on _UNICODE flag, e.g. ... I think that in these days those ANSI strings are something from the ...
    (microsoft.public.vc.mfc)
  • Re: Want Input boxes to accept unicode strings on Standard Window
    ... strings with _T ... pattern) but these blow up immediately. ... as a "massive effort" or, in one case, "we need a complete rewrite in Unicode and can't ... the process a couple of times the conversion thing is pretty academic. ...
    (microsoft.public.vc.mfc)

Loading