Error C2079 Cstring
Contents |
of our projects without modification, but got the WINVER problem. So I fixed that, then tried to build again... This time, I got CString errors. I looked up the HELP, and found Q309801 "PRB: Linking Errors When You error c2079 uses undefined class Import CString-Derived Classes" (http://support.microsoft.com/default...;EN-US;Q309801). This suggests adding the following 2 lines to stdafx.h :- template class
Error C2079 Uses Undefined Struct
__declspec(dllimport) CStringT
C++ Undefined Class
of the relevant threads have been left hanging without a solution. Does anyone know how to solve this CString problem? (Is this the right forum for this question?) December 20th, 2004, 02:49 PM Andreas Masur Re: Migrating from 6.0 to .NET Completely off the top of my head...'CString' is now a template class...thus...the following should work (hope I get it right)... Code: class CScanString : public CStringT
it. Sry if there is one like this. Well my problem is about CArray and Structs... Lets see if someone could give me some guidelines :) I declare a struct in the header: 1
2
3
4
5
struct M{ CString a; CString b; CArray
2
3
4
CArray
2
3
4
5
6
7
8
9
10
struct M{ CString a; CString b; CArray
2
3
4
5
6
7
8
9
10
11
12
struct Met{ CString a; CString b; CArray<
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us http://stackoverflow.com/questions/4797747/c-compiler-error-with-stringbuf-ifstream Learn more about Stack Overflow the company Business Learn more about hiring developers http://microsoft.public.vc.mfc.narkive.com/C9w6IzKQ/problems-with-cstring-conversion-from-vc6-to-vc2005 or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up C++ compiler error with stringbuf / ifstream up error c2079 vote 1 down vote favorite I cannot understand why my compiler (MSVC++2010) doesn't like this code: // get_sum(filename as c-string) returns sum from file int get_sum(const char* const s) { stringbuf bill_buf; ifstream bill_file; bill_file.open(s); bill_file.get(bill_buf, '\0'); // read whole file bill_file.close(); return get_sum_from_string(bill_buf.str()); } I get these errors (I translated them from German to English and give the correct line numbers for the code excerpt without error c2079 uses leading comment): Error 1 error C2079: 'bill_buf' uses undefined class 'std::basic_stringbuf<_Elem,_Traits,_Alloc>' (Line 2) Error 2 error C2664: 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::get(_Elem *,std::streamsize)': Conversion of parameter 1 from 'int' to 'char *' not possible (Line 5) Error 3 error C2228: To the left of ".str" there must be a class/structure/union. (Line 7) Has anyone got an idea what's going on there? Thanks a lot! (If anyone has got a better idea how to quickly get the whole file contents into a string, I'd also appreciate it) c++ file-io compiler-errors share|improve this question asked Jan 25 '11 at 19:08 Felix Dombek 3,97863668 2 Errors 2 and 3 are side-effects of #1. Did you specify 'using std'? Do you have the correct header file for stringbuf? –Chris O Jan 25 '11 at 19:10 you're missing an include file that defines stringbug... Now which one was it. –user180326 Jan 25 '11 at 19:11 That's right, I just did include
I have acompiling problem. Following error:error C2079: 'myString' uses undefined class 'CString'.CString should now be a template in place of a class.By another project theres is a forward declaration of 'class CString'.I get the following message:error C2371: 'CString' : redefinition; different basic typesThats an indication for the template, but what do I have to do tocompile my project again.Regards,Matthias Vipin [MVP] 2006-01-27 16:03:40 UTC PermalinkRaw Message looks like a header file path issue. It seems that when you compile, it isstillpicking the afx.h in vc++6.0 while in vs .net2003 it should be a templatepickup fromafxstr.h header file.Are you building from VS IDE or via a makefile?--Vipin AravindPost by Matthias MeierHi all,I have converted a project from VC6.0 to VC2005 (MFC). Now I have aerror C2079: 'myString' uses undefined class 'CString'.CString should now be a template in place of a class.By another project theres is a forward declaration of 'class CString'.error C2371: 'CString' : redefinition; different basic typesThats an indication for the template, but what do I have to do tocompile my project again.Regards,Matthias Matthias Meier 2006-01-27 16:20:13 UTC PermalinkRaw Message Hi Vipin,thanks for your answer. I'm building from VS2005 IDE.Regards,Matthias Vipin [MVP] 2006-01-27 16:44:38 UTC PermalinkRaw Message Firstly do a rebuild all to be sure.If that doesn't work. Go to c/c++->Prepreocessor, turn on generatepreprocessed file.your compilation will fail anyway. Go to the directory there will becorresponding files withthe .i extension. open them and search for CString. See where it is pickingfrom.Also see if in the include dir path(compiler option /I), if it is pointingto Vc6 include directories.Also check tools->options->projects->vc++ directories->include directories.I am using vc6 and vs .net 2003 at home and having VS2005 at office.Since I am at home, I can only troubleshoot from VS.net 2003 perspective.--Vipin AravindPost by Matthias MeierHi Vipin,thanks for your answer. I'm building from VS2005 IDE.Regards,Matthias Alexander Grigoriev 2006-01-28 05:12:41 UTC PermalinkRaw Message Don't add 'class' to CString name. It's actually a typedef in VC2002+.Post by Matthias MeierHi all,I have converted a project from VC6.0 to VC2005 (MFC). Now I have aerror C2079: 'myString' uses undefined class 'CString'.CString should now be a template in place of a class.By another project theres is a forward declaration of 'class CString'.error C2371: 'CString' : redefinition; different basic typesThats an