We help IT Professionals succeed at work.

error C2065: undeclared identifier

PMH4514
PMH4514 asked
on
8,897 Views
Last Modified: 2013-11-20
After rebuilding my development computer as XP Pro (instead of Win2k) using Visual C++ 6.0 with the Microsoft C++ 2005 Redistributable installed,  I'm trying to recompile code that always used to compile. Now though I'm getting these errors:

error C2065: '_tcscat_instead_use_StringCbCat_or_StringCchCat' : undeclared identifier
error C2065: '_tcscpy_instead_use_StringCbCopy_or_StringCchCopy' : undeclared identifier
error C2065: 'sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA' : undeclared identifier
error C2065: '_stprintf_instead_use_StringCbPrintf_or_StringCchPrintf' : undeclared identifier
error C2065: 'strcpy_instead_use_StringCbCopyA_or_StringCchCopyA' : undeclared identifier

What might be wrong?

thanks
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2009

Commented:
Those are pretty weird identifiers :

        _tcscat_instead_use_StringCbCat_or_StringCchCat

I assume that you have to replace that with either StringCbCat or StringCchCat.
CERTIFIED EXPERT
Top Expert 2012
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Somebody has decided that you shouldn't be using the tcscat, tcscpy, sprintf or strcpy functions.  They went into your header files and replaced the definitions of these functions with big long nonexistent identifiers like _tcscat_instead_use_StringCbCat_or_StringCchCat that cause compile and/or linking errors.  

The best way to deal with this is probably to rewrite your code to use the StringCbCat and StringCchCat functions instead of the other functions that are denied to you.
jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
BTW, check out the file "PlatformSDK\Include\strsafe.h" which is responsible for that strange name mapping.
CERTIFIED EXPERT
Top Expert 2009

Commented:
>> BTW, check out the file "PlatformSDK\Include\strsafe.h" which is responsible for that strange name mapping.

Wow, I wonder who came up with this idea ... It's a pretty weird way of reporting a deprecated method.
jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
The new PSDK tries to force you to use the safety-improved (non standard!) versions of their string functions. But, that simply is not possible without VC++ 8.
>>>> using Visual C++ 6.0 with the Microsoft C++ 2005 Redistributable installed,
You are using some wrong include folders for VC6. I assume you are using the new platform sdk. That comes if you installed VC6 after the new SDK and so have the SDK folders as 'default' include and library project folders in the settings at 'Tools - Options - Directories'. I would strongly recommend to remove them (the new SDK folders) from there cause you may experience other incompatibilities if you do not.

Note, if you build from the command line you also must check the 'include' and 'lib' environment variable, which may contain the folders as well. You have to make them switchable in that case.

Regards, Alex

Author

Commented:
Hmm.. For reference, this is the actual code that it's complaining on:

      _tcscat( m_lpszUIProductName, PRODUCT_NAME );
    _tcscpy( m_lpszUIVersion, PRODUCT_SYMBOLS );
      _tcscat( m_lpszUIVersion, PRODUCT_VERSION );
      _tcscat( m_lpszUIVersion, SERVICE_PACK );
    _tcscat( m_lpszUIVersion, BUILD );
    _tcscat( m_lpszUIVersion, EXTENSION );
    _tcscat( m_lpszReleaseDate, RELEASE_DATE );
    _tcscat( m_lpszBuildDate, BUILD_DATE );
    _tcscat( m_lpszSchema, SCHEMA );


each of those constants is just a definition like this:

#define PRODUCT_NAME _T("MyApp")

When I rebuild my development computer I installed the Platform SDK first, and then VC++ 6.0

When I remove the include/library folders from the project settings for the platform SDK and try to recompile, I get this error:

fatal error C1083: Cannot open include file: 'Qedit.h': No such file or directory

Again, this did all used to work just fine before I rebuilt my dev computer.



jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
So, do you have both VC6 and VC8 installed or just VC6 with a newer PSDK? If the latter applies, try my suggestion above.
>>>> fatal error C1083: Cannot open include file: 'Qedit.h':
The qedit.h is a file that didn't come with VC6 but with the platform sdk. You would need to install an older version of the platform sdk (best copy the folders from a machine where the old sdk was installed) and add the include and library path to the directories settings in VC6.

Note, you could try to get it working using the newer SDK, but I really recomemnd against. VC6 and VC8 have no much in common and the were developed by different teams who didn't much look for compatibility. I know cause we ported a huge system from VC6 to VC8 and we ever failed when not strictly separating the development environments.

Author

Commented:
I am pretty certain I installed the platform SDK from the same installer that I had previously used.  I did not locate and download a new version.  I only have VC6 installed. How can I determine the version of the Platform SDK?

Author

Commented:
.. additionally - another of our developers has no problem compiling the same code. If I were to merely copy the entire contents of her "\Microsoft Platform SDK" folder overwriting my folder of the same name, would that effectively replace my version with the version that works? Or are other things installed into the OS?

Author

Commented:
I overwrote the contents of my Microsoft Platform SDK folder with the contents of the same folder from another developer's computer, one on which the code compiles without error.

I still get errors. Not all of them, a shorter list:

_tcscat( m_lpszUIProductName, PRODUCT_NAME );
_tcscpy( m_lpszUIVersion, PRODUCT_SYMBOLS );
sprintf(m_lpszStandardFontBold, "%s Bold", m_lpszStandardFont);
_stprintf(lpszBuffer, _T("%d"), a_iPower);
strcpy(m_lpszLocalDBPath, m_lpszDefaultDBPath);


Author

Commented:
woops, forgive that last post.. It should read:
------------------
error C2065: '_tcscat_instead_use_StringCbCat_or_StringCchCat' : undeclared identifier
error C2065: '_tcscpy_instead_use_StringCbCopy_or_StringCchCopy' : undeclared identifier
error C2065: 'sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA' : undeclared identifier
error C2065: '_stprintf_instead_use_StringCbPrintf_or_StringCchPrintf' : undeclared identifier
error C2065: 'strcpy_instead_use_StringCbCopyA_or_StringCchCopyA' : undeclared identifier


on these lines:

_tcscat( m_lpszUIProductName, PRODUCT_NAME );
_tcscpy( m_lpszUIVersion, PRODUCT_SYMBOLS );
sprintf(m_lpszStandardFontBold, "%s Bold", m_lpszStandardFont);
_stprintf(lpszBuffer, _T("%d"), a_iPower);
strcpy(m_lpszLocalDBPath, m_lpszDefaultDBPath);

Author

Commented:
JKR Wrote: "BTW, check out the file "PlatformSDK\Include\strsafe.h" which is responsible for that strange name mapping."

I looked into that file, and determined from it that I could add this line to stdafx.h

#define STRSAFE_NO_DEPRECATE

and the compile succeeds.

But have I opened up a can of worms by doing so?
jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
Actually, it should be the other way round (as above). Strange...

Author

Commented:
yah, I noticed that.. I had originally missed your first comment (the one I accepted)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.