stupid question? CStrings are killin' me.

Discussion in 'C++' started by raz, Jun 15, 2004.

  1. raz

    raz Guest

    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.
     
    raz, Jun 15, 2004
    #1
    1. Advertisements

  2. raz

    Sharad Kala Guest

    "raz" <> wrote in message
    news:...
    > 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.
     
    Sharad Kala, Jun 15, 2004
    #2
    1. Advertisements

  3. raz

    Pete C. Guest

    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
     
    Pete C., Jun 15, 2004
    #3
  4. "raz" <> wrote in message
    news:...
    > 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
     
    John Harrison, Jun 15, 2004
    #4
  5. "raz" <> schrieb im Newsbeitrag
    news:...
    > 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
     
    Gernot Frisch, Jun 16, 2004
    #5
  6. raz

    raz Guest

    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
     
    raz, Jun 16, 2004
    #6
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael W Cocke

    Stupid RE question

    Michael W Cocke, Dec 27, 2004, in forum: Perl
    Replies:
    2
    Views:
    468
    Michael W Cocke
    Dec 28, 2004
  2. Steve

    Is this a stupid question?

    Steve, Jul 17, 2003, in forum: ASP .Net
    Replies:
    6
    Views:
    392
    Mario Vargas
    Jul 17, 2003
  3. Rob Richardson

    Stringstreams and CStrings

    Rob Richardson, Jul 11, 2003, in forum: C++
    Replies:
    2
    Views:
    976
    wpcmame
    Jul 12, 2003
  4. Brandon McCombs
    Replies:
    4
    Views:
    569
    Richard Wheeldon
    Aug 28, 2006
  5. rincewind

    stupid, STUPID question!

    rincewind, Apr 19, 2009, in forum: HTML
    Replies:
    25
    Views:
    1,108
Loading...

Share This Page