stupid question? CStrings are killin' me.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • raz

    stupid question? CStrings are killin' me.

    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\File Set.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.
  • John Harrison

    #2
    Re: stupid question? CStrings are killin' me.


    "raz" <raz@poetworld. net> wrote in message
    news:fa3e2be.04 06150427.774e5b 98@posting.goog le.com...[color=blue]
    > 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?
    >[/color]

    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.program mer.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


    Comment

    • Sharad Kala

      #3
      Re: stupid question? CStrings are killin' me.


      "raz" <raz@poetworld. net> wrote in message
      news:fa3e2be.04 06150427.774e5b 98@posting.goog le.com...[color=blue]
      > 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:[/color]

      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.


      Comment

      • Pete C.

        #4
        Re: stupid question? CStrings are killin' me.

        raz wrote:[color=blue]
        > 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?
        >[/color]
        <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.publi c.vc.mfc.

        - Pete




        Comment

        • Gernot Frisch

          #5
          Re: stupid question? CStrings are killin' me.


          "raz" <raz@poetworld. net> schrieb im Newsbeitrag
          news:fa3e2be.04 06150427.774e5b 98@posting.goog le.com...[color=blue]
          > 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[/color]
          the[color=blue]
          > 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[/color]
          class:[color=blue]
          >
          > 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\File Set.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.[/color]

          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





          Comment

          • raz

            #6
            Re: stupid question? CStrings are killin' me.

            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

            Comment

            Working...