stupid question? CStrings are killin' me.

R

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.
 
S

Sharad Kala

raz said:
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.
 
P

Pete C.

raz said:
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
 
J

John Harrison

raz said:
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

(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
 
G

Gernot Frisch

raz said:
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
 
R

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top