VC升级时出现的问题

ATL and CRT
  • ATL
  • CRT

Active Template Library (ATL)

!!! 除了IE的ActiveX项目,不推荐ATL !!!
!!! ATL is not recommended except for IE ActiveX projects. !!!

C1189

c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcore.h(35):
fatal error C1189: #error :  This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended.

A:

StdAfx.h

#define _WIN32_WINNT 0x0400

->

#define _WIN32_WINNT 0x0501

C1083(atlimpl)

c:\users\xiaobin\documents\visual studio 2013\projects\crcfcn_vc\stdafx.cpp(13):
fatal error C1083: Cannot open include file: 'atlimpl.cpp': No such file or directory

A: solution 1 or 2.

  • solution 1
    Comment out this line
    stdAfx.cpp
// stdafx.cpp : source file that includes just the standard includes
//  stdafx.pch will be the pre-compiled header
//  stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

#ifdef _ATL_STATIC_REGISTRY
#include <statreg.h>
#include <statreg.cpp>
#endif

//#include <atlimpl.cpp>
  • solution 2
    Copy this file to the Project folder,

    atlimpl.cpp

// This is a part of the Active Template Library.
// Copyright (C) Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Active Template Library Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Active Template Library product.

#pragma message("atlimpl.cpp is obsolete. Please remove it from your project.")

/////////////////////////////////////////////////////////////////////////////
// No longer used

and modify the reference path.

stdAfx.cpp

// stdafx.cpp : source file that includes just the standard includes
//  stdafx.pch will be the pre-compiled header
//  stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

#ifdef _ATL_STATIC_REGISTRY
#include <statreg.h>
#include <statreg.cpp>
#endif

#include "atlimpl.cpp"

file format(.dsw and .dsp)

Download the source code (released)  

Q: When opening a project, “cannot load the project due to a corrupt project file”. 

A: Just convert .dsw and .dsp to “Windows (CR LF)". 

Error D8016

Q: ‘/ZI’ and ‘/Gy-’ command-line options are incompatible    

A: Configuration Properties -> C/C++ -> Debug Information Format        Program Database for Edit And Continue(/ZI) => Program Database(/Zi)

Error MSB3075

Q: The command “regsvr32 /s /c “D:\projects\crcfcn - Copy.\Debug\FCV.dll”       echo regsvr32 exec. time > “.\Debug\regsvr32.trg”    

A: Project > Properties > Configuration Properties > Custom Build Step     Command line: Empty content.       https://social.msdn.microsoft.com/Forums/vstudio/en-US/97f50350-e37a-46ba-a921-8f4afa29db03/error-msb3073-exited-with-code-3

error MSB8011

A: Project–>Propertier–>Linker–>General–>Register Output–>NO

Excluded files

提交代码时不需要的文件

  • MIDL
_.i.h, _.i.c, _.p.c
  • resource
.aps
  • PS

vc10建立atl会生成一个ps的工程 Proxy and Stub

In other words, interfaces that derive from IDispatch and only use Automation compatible types.
You only need to get the registry entries right to enable it and
don't otherwise need the proxy/stub generated by midl.

Register Output

更改为不在注册表注册!

“project property” -> “Configuration Properties” -> “Linker”: “Register Output”为 “No”;

Validate Parameters

“project property” ->“Configuration Properties”->"MIDL"->“Advanced”: "Validate Parameters"为“Yes(/robust)”

CRT

C runtime Library (CRT)

C1019

stdAfx.h issue:

unexpected #else

如果文件中有stdafx.h, 需要把它放在#include的首行。

C4996

'localtime': This function or variable may be unsafe. 
Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
  • vs2012-vs2013
    在stdafx.h 最上面的次一行加入:
#define _CRT_SECURE_NO_DEPRECATE
  • vs2015+
    在文件首行加入:
#define _CRT_SECURE_NO_WARNINGS

C2039

'InitializeCriticalSectionAndSpinCount' : is not a member of '`global namespace''

update _WIN32_WINNT version.

C1083

Cannot open include file: 'atlimpl.cpp': No such file or directory

In VS 12 at least atlimpl.cpp is not even present.

LNK2001

  • IDE: Visual Studio 2015 update 3
  • Windows Driver Kit Version 7.1.0

Sandboxie

at SboxDrv project:

Error LNK2001 unresolved external symbol _memcmp SboxDrv C:\Users\tdtc\Documents\sandboxie\core\drv\XXX.obj

XXX:

process_force.obj
syscall.obj
token.obj
util.obj
gui.obj
ipc.obj
key.obj
process.obj

Solution

project setting and David Xanatos

because VS 2015.3 encounters some linker errors in SBoxDll,
like "unresolved external symbol memcmp", "unresolved external symbol memmove" and so on
To resolve the issue I had to add to the linker vcruntime.lib, libucrt.lib and libcmt.lib

properties->Linker->Input->Additional Dependencies

vcruntime.lib

Character constant

Syntax:

format description memo
‘c-char ' (1) -
u8’c-char ' (2) (since C23)
u’c-char ' (3) (since C11)
U’c-char ' (4) (since C11)
L’c-char ' (5) -
‘c-char-sequence ' (6) -
L’c-char-sequence ' (7) -
u’c-char-sequence ' (8) (since C11)(removed in C23)
U’c-char-sequence ' (9) (since C11)(removed in C23)

Example of virtualbox:

v7.0.6

L"Winmgmt\0RpcSs\0\0",           /* lpDependencies */

Multibyte vs Wide Characters

A multibyte character is a character composed of sequences of one or more bytes. 
Each byte sequence represents a single character in the extended character set. 
Multibyte characters are used in character sets such as Kanji.

Wide characters are multilingual character codes that are always 16 bits wide. 
The type for character constants is char; for wide characters, the type is wchar_t. 
Since wide characters are always a fixed size, using wide characters simplifies programming with international character sets.

The wide-character-string literal L"hello" becomes an array of six integers of type wchar_t.

Reference