Compile error [SOLVED]

On 26/11/2014 at 08:16, xxxxxxxx wrote:


I'd like to clarify why these compiler version upgrade / mismatch related problems occur, as they are issues that will reoccur in the future when upgrading to VS2013 and beyond.

1. Updated code causes fatal error C1004 with VS2010 target toolset

Unfortunately, MSDN does not explain the real reason why

fatal error C1004: unexpected end-of-file found!

occurs in this case. MSDN should state: 'You are attempting to compile code written for a different version of the C++ grammar.' as a potential reason. Here's why:

- A programming language grammar is the set of rigidly defined rules that describe all syntactically valid programs for that language.  A particular version of a compiler might only include a subset of a grammar if its developers leave out non-essential features for future implementation.

- Grammars themselves can be changed over time by those in charge of its standardization.  The relatively new C++11 standard includes a lot of new features that required additions to the C++ grammar.

That's why when you try compiling code written for VS2012 that uses a feature related to the newly added grammar with an older compiler target, such as VS2010, the older compiler goes astray early in the process.  The resulting error can be any one of those that practically mean "Your code doesn't make sense to me at a fundamental level" (ie 'syntax error', 'missing < symbol >', etc.).

It also means that, unless you're willing to chop out or rewrite new code, you must upgrade to the new target toolset, as there's no going back to the older C++ dialect.

2. fatal error C1051: program database file, '<path to pdb file>', has an obsolete format, delete it and recompile

This error occurs due to not deleting files created the last time VS2010 was used to compile the code.  This can lead to all sorts of mismatch issues with a newer compiler, some of which may not even be pointed out explicitly.  It's therefore best that you first clean out your projects with the old Visual Studio (Build menu, 'Clean Solution' option) for every target (64 bit debug and 64 bit release) before attempting the upgrade.

3. Path problems, such as with "\_api.lib", after a compiler upgrade

If you look in your project's properties, you'll discover various directory paths written with macros.  These macros change over time, and the upgrade process doesn't always do the proper conversion.  You have to figure out the differences from the old to the new compiler, and adjust your new project's directory paths accordingly, using the new macros.  It's certainly a pain, but a necessary evil.  Warning: if you hard code the paths, you'll run into bigger problems down the road, especially when making a future compiler upgrade.

I hope that helps!

Joey Gaspe
SDK Support Engineer