what gives? cstring template issues

D

dotnetchic

In VS 2003, I try creating a new VC7 MFC dll. Accepting all defaults,
before adding ANY code, I get compiler errors out the wazoo having to
do with this CString template. I ran across the same problem in
porting some code over and compiling with the /clr switch and I
resolved that issue by modifying a section of code that was typecasting
a byte to a string (AFTER about a half-day of figuring out the right
compiler options, and then realizing I needed to change them for EVERY
SINGLE SOURCE FILE in the project, which I managed to accomplish with
find/replace in notepad, but only AFTER dancing through hoops). But my
current errors must be in the default project settings, or somewhere
??!! Because I haven't written a single line of source yet.

IJW my AS$ !

TIA
 
B

Bruno van Dooren

I just added a new MFC dll project to a VS2003 solution, accepted the
defaults (no automation, no sockets, using MFC in a shared dll).
everything builds without a problem.
No CString errors or anything.

did you modify your environment or project settings, or anything else?
what are the compiler errors you get?

kind regards,
Bruno.
 
D

dotnetchic

Following the same steps you describe, I get the rather cryptic output
message (several similar):

c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\atlmfc\include\cstringt.h(868) : error C2143: syntax error :
missing ';' before 'template'

along with many of the following compiler errors (mostly syntax
errors):
C2146, C2252, C2252, C2501, C2653, C2334,
which all revolve around compilation of stdafx.cpp. I haven't changed
any project settings, and nothing looks out of line... ?
 
D

dotnetchic

Has anyone else had this problem with cstrings / templates? Any
suggestion what I might can try? I'm trying to bring a new project
over to vc++7, or preferrably c#, but I can't seem to make any progress.
 
B

Bruno van Dooren

Hi,
dotnetchic said:
Has anyone else had this problem with cstrings / templates? Any
suggestion what I might can try? I'm trying to bring a new project
over to vc++7, or preferrably c#, but I can't seem to make any progress.

Could you prehaps post a project that reproduces this behavior?
If you have this problem with a newly created project, then compiling it on
my side should quickly show if the problem is in your project or your
environment.

--

Kind regards,
Bruno.
(e-mail address removed)
Remove only "_nos_pam"
 
D

dotnetchic

my lib and include paths are the same as yours above. I am unable to
compare your build log against mine, though...can you send to my e-mail?
 
A

Arnaud Debaene

dotnetchic said:
my lib and include paths are the same as yours above. I am unable to
compare your build log against mine, though...can you send to my
e-mail?

Have you modified the cstringt.h header? Post a snippet of this file around
line 868.

Arnaud
MVP - VC
 
D

dotnetchic

To my knowledge, cstringt.h has not been modified (at least not by
yours truly). See anything unusual?


#ifndef _MANAGED

This template will compile only for
class SystemString == System::String

template<class SystemString>
CStringT( SystemString * pString ) :
CThisSimpleString( StringTraits::GetDefaultManager() )
{
const wchar_t __pin* psz = PtrToStringChars( pString );
*this = psz;
}
#endif
 
B

Bruno van Dooren

Hi,
#ifndef _MANAGED
in my header, this is #ifdef, not #ifndef
This template will compile only for
class SystemString == System::String
the // comment characters are missing at the start of these 2 lines.

judging by this, your headers are different from what they should be.
In one of your previous posts, you mentioned that you had to manually edit a
lot of files.
maybe you accidently edited the header?

I don't know if there is a good way to repair the headers or not.
if you have to do it by hand, the simplest thing might be to just reinstall
VS.

--

Kind regards,
Bruno.
(e-mail address removed)
Remove only "_nos_pam"
 
D

dotnetchic

Right. The comments are kinda suspicious, huh?

Actually, I had to manually change the BasicRuntimeChecks settings for
each file included in the project, and ended up manually editing the
project file. So my editing was isolated to the one file, not
affecting any headers.

I just changed the directive and everything compiled. Hmmm... Note to
self: keep the boss out of the source files!!

Well, thanks for your help. At least I'm back to square 1 with my code
port. Cheers!
 

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

Top