By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,161 Members | 1,132 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,161 IT Pros & Developers. It's quick & easy.

stupid question? CStrings are killin' me.

P: n/a
raz
Greetings all.

I apologize for what is almost certainly a stupid question, but I
can't figure this out, and have no more time for head bashing...
The short version: what is the appropriate include file to define the
CString type in an MFC based app?

The longer version:

I have a Windows App, in MFC and am trying to use CStrings in a class:

class foo
{
foo();
~foo();

public:
CString m_path;

void setFileName (CString name);

<etc>
}

but when compiling it, I get a boatload of compiler errors because
CString is apparently unknown as type.
c:\DNA\app\BDTS\BDTS\BDTS\FileSet.h(32): error C2146: syntax error :
missing ';' before identifier 'm_path'
If I include "stdafx.h" it will compile, but then later files in the
project fail to compile because WINDOWS is already defined.

I have tried #include <atlstr.h> which sort of works, but fails at
link time
and <cstringt.h> which does no good.

This has *got* to be simple and stupid (on my part), but I don't get
it...

Any help appreciated!

-raz.
Jul 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

"raz" <ra*@poetworld.net> wrote in message
news:fa*************************@posting.google.co m...
Greetings all.

I apologize for what is almost certainly a stupid question, but I
can't figure this out, and have no more time for head bashing...
The short version: what is the appropriate include file to define the
CString type in an MFC based app?


CStrings are not part of the standard C++ language, so are off topic here.
Please ask again in a Windows programming group such as
news:comp.os.ms-windows.programmer.tools.mfc

(I would suggest just searching through the headers files for the one that
contains the CString definition, but I know MS headers too well to know that
won't necessarily give you the right answer)

john
Jul 22 '05 #2

P: n/a

"raz" <ra*@poetworld.net> wrote in message
news:fa*************************@posting.google.co m...
Greetings all.

I apologize for what is almost certainly a stupid question, but I
can't figure this out, and have no more time for head bashing...
The short version: what is the appropriate include file to define the
CString type in an MFC based app?

The longer version:


Hey standard C++ doesn't know of class CString at all. having said that i think
it's <afx.h>that you need to include, IIRC.
Jul 22 '05 #3

P: n/a
raz wrote:
Greetings all.

I apologize for what is almost certainly a stupid question, but I
can't figure this out, and have no more time for head bashing...
The short version: what is the appropriate include file to define the
CString type in an MFC based app?

<snip>

I think it's <afxwin.h> or <afx.h>, but MFC is not topical here (only
standard C++ is). If those don't work, try asking in
microsoft.public.vc.mfc.

- Pete


Jul 22 '05 #4

P: n/a

"raz" <ra*@poetworld.net> schrieb im Newsbeitrag
news:fa*************************@posting.google.co m...
Greetings all.

I apologize for what is almost certainly a stupid question, but I
can't figure this out, and have no more time for head bashing...
The short version: what is the appropriate include file to define the CString type in an MFC based app?

The longer version:

I have a Windows App, in MFC and am trying to use CStrings in a class:
class foo
{
foo();
~foo();

public:
CString m_path;

void setFileName (CString name);

<etc>
}

but when compiling it, I get a boatload of compiler errors because
CString is apparently unknown as type.
c:\DNA\app\BDTS\BDTS\BDTS\FileSet.h(32): error C2146: syntax error :
missing ';' before identifier 'm_path'
If I include "stdafx.h" it will compile, but then later files in the
project fail to compile because WINDOWS is already defined.

I have tried #include <atlstr.h> which sort of works, but fails at
link time
and <cstringt.h> which does no good.

This has *got* to be simple and stupid (on my part), but I don't get
it...

Any help appreciated!

-raz.


Visual Studio 6.x I suggest. From the project options, Compiler,
Preprocessor add ".\" as an include path. The stdafx.h your compiler
find might be from a dos-program you wrote before.

HTH,
-Gernot

Jul 22 '05 #5

P: n/a
raz
Apologies to all for the off-topic post.

I thought it may be off-topic, but a quick scan of articles looked
like MS specific questions were applicable. Sorry.

FWIW: I solved the problem, but could not remove the post. Thanks
everyone for the help and the gentle indicators that I was
inappropriate.

Thanks!

-raz
Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.