DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: #include <string> mfc app

  1. #1
    Guest

    #include <string> mfc app


    I need to use a header and implementation file which includes the ANSI class
    string. But when I include these files into my mfc application I get a bunch
    of compiler errors. I normally use CString in mfc apps but since the header
    files are used in none mfc apps I must find a way to allow string. Here
    are a few of the errors from vc++ 6.0:

    c:\program files\microsoft visual studio\vc98\include\new(35) : error C2061:
    syntax error : identifier 'THIS_FILE'
    c:\program files\microsoft visual studio\vc98\include\new(35) : error C2091:
    function returns function
    c:\program files\microsoft visual studio\vc98\include\new(35) : error C2809:
    'operator new' has no formal parameters


  2. #2
    ralph Guest

    Re: #include <string> mfc app


    <cplus.@127.0.0.1> wrote:
    >
    >I need to use a header and implementation file which includes the ANSI class
    >string. But when I include these files into my mfc application I get a

    bunch
    >of compiler errors. I normally use CString in mfc apps but since the header
    >files are used in none mfc apps I must find a way to allow string. Here
    >are a few of the errors from vc++ 6.0:
    >
    >c:\program files\microsoft visual studio\vc98\include\new(35) : error C2061:
    >syntax error : identifier 'THIS_FILE'
    >c:\program files\microsoft visual studio\vc98\include\new(35) : error C2091:
    >function returns function
    >c:\program files\microsoft visual studio\vc98\include\new(35) : error C2809:
    >'operator new' has no formal parameters
    >


    Move the #include <string> directive before the conditional block.
    #include <string>
    #ifdef _DEBUG
    ...
    #endif

    Also it is not wise to casually mix MBCS, Unicode, and ANSI strings in an
    MFC application. You can save yourself a lot of trouble by using TCHAR/TCHAR.H.

    typedef std::basic_string<TCHAR> tstring;





  3. #3
    Guest

    Re: #include <string> mfc app


    "ralph" <nt_consulting32@hotmail.com> wrote:
    >
    ><cplus.@127.0.0.1> wrote:
    >>
    >>I need to use a header and implementation file which includes the ANSI

    class
    >>string. But when I include these files into my mfc application I get a

    >bunch
    >>of compiler errors. I normally use CString in mfc apps but since the header
    >>files are used in none mfc apps I must find a way to allow string. Here
    >>are a few of the errors from vc++ 6.0:
    >>
    >>c:\program files\microsoft visual studio\vc98\include\new(35) : error C2061:
    >>syntax error : identifier 'THIS_FILE'
    >>c:\program files\microsoft visual studio\vc98\include\new(35) : error C2091:
    >>function returns function
    >>c:\program files\microsoft visual studio\vc98\include\new(35) : error C2809:
    >>'operator new' has no formal parameters
    >>

    >
    >Move the #include <string> directive before the conditional block.
    > #include <string>
    > #ifdef _DEBUG
    > ...
    > #endif
    >
    >Also it is not wise to casually mix MBCS, Unicode, and ANSI strings in an
    >MFC application. You can save yourself a lot of trouble by using TCHAR/TCHAR.H.
    >
    >typedef std::basic_string<TCHAR> tstring;
    >
    >
    >
    >

    I appreciate the help and that did solve the problem. Also I'll take your
    advice and look into converting to tchars. Thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center