From: Igor Tandetnik on
"Jung, William" <aopiyy001(a)yahoo.com> wrote in message
news:elrvm4hlb3c7eh9f1v75ihf1i7lalc0g5h(a)4ax.com
> On Thu, 15 Jan 2009 21:12:09 -0500, "Igor Tandetnik"
> <itandetnik(a)mvps.org> wrote:
>
>> "Jung, William" <aopiyy001(a)yahoo.com> wrote in message
>> news:3pqvm451m5v1et94j4dlj40u2gamiq35h0(a)4ax.com
>>> 1>C:\Program Files\Microsoft Visual Studio
>>> 8\VC\atlmfc\include\afxstr.h(20) : fatal error C1189: #error :
>>> afxstr.h can only be used in MFC projects. Use atlstr.h
>>
>> So, have you tried atlstr.h instead of afxstr.h?
>
> this one works thanks!
>
> so both atlstr.h + afxstr.h have some CString code?

They both reuse the same code, with slightly different settings -
mainly, different memory allocators.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


From: David Webber on

"Igor Tandetnik" <itandetnik(a)mvps.org> wrote in message
news:OMbYDN4dJHA.3968(a)TK2MSFTNGP06.phx.gbl...

> They both reuse the same code, with slightly different settings - mainly,
> different memory allocators.

And it's a right royal pain if you have one DLL using MFC, and another one
not, and you want to pass CStrings back and forth: basically it doesn't
work. :-(

Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm

From: Igor Tandetnik on
David Webber <dave(a)musical-dot-demon-dot-co.uk> wrote:
> "Igor Tandetnik" <itandetnik(a)mvps.org> wrote in message
> news:OMbYDN4dJHA.3968(a)TK2MSFTNGP06.phx.gbl...
>
>> They both reuse the same code, with slightly different settings -
>> mainly, different memory allocators.
>
> And it's a right royal pain if you have one DLL using MFC, and
> another one not, and you want to pass CStrings back and forth:
> basically it doesn't work. :-(

Rule of thumb: passing C++ classes - CString or otherwise - across
module boundaries only works when all modules are built by the same
compiler with the same options, and is best avoided in any case.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


From: Giovanni Dicanio on

"Igor Tandetnik" <itandetnik(a)mvps.org> ha scritto nel messaggio
news:eXOMFCAeJHA.1336(a)TK2MSFTNGP02.phx.gbl...

> Rule of thumb: passing C++ classes - CString or otherwise - across module
> boundaries only works when all modules are built by the same compiler with
> the same options, and is best avoided in any case.

I do agree.

....I think that this was one of the reasons why COM was invented, too.

Giovanni


From: Tom Serface on
I see you found the solution (using atlstr.h for using CString outside of an
MFC project), however I think you should also get into the habit of putting
strings in the Unicode/ANSI quotes like:

CString idle_cmd_on = _T("aaaa");

So you don't get translation errors if you decide to go to a Unicode build.
If you are only doing Unicode you could use this form:

CString idle_cmd_on = L"aaaa";

CString has the habit of converting strings for you so you may not get a
compile error and yet not end up with what you intended.

CString is still a powerful animal and worthy of use in spite of this, um,
feature.

Also, I think you will find adding all of MFC to your projects will increase
the size by around 150K (the EXE size) so it may be easier to just create
projects that way rather than trying to work around it (if you need any part
of MFC's functionality).

Tom

"Jung, William" <aopiyy001(a)yahoo.com> wrote in message
news:ganvm4h176g3ep843b9d4l95tqk5voae30(a)4ax.com...
> why the following gets error
>
> #include <iostream>
> #include <string.h>
> #include <string>
> using std::cout;
> using std::endl;
>
>
> int main()
> {
>
>
> CString idle_cmd_on = "aaaa";
>
>
> }
>
> 1>..\..\myCode\string.cpp(21) : error C2065: 'CString' : undeclared
> identifier