#include <dbghelp.h>不包含标头

时间:2017-04-07 17:27:02

标签: c++

如果在例如控制台C ++应用程序中包含#include <Dbghelp.h>,它将不会从头文件中带来任何定义,并且存在或多或少类似的编译器错误,就好像根本不包含此标头一样。

编译器错误如下:

1>------ Build started: Project: ConsoleDump, Configuration: Debug Win32 ------
1>  ConsoleDump.cpp
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(23): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(23): error C2146: syntax error: missing ';' before identifier 'Flags'
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(23): error C2065: 'Flags': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(23): error C2065: 'MiniDumpWithFullMemory': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(24): error C2065: 'MiniDumpWithFullMemoryInfo': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(25): error C2065: 'MiniDumpWithHandleData': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(26): error C2065: 'MiniDumpWithUnloadedModules': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(27): error C2065: 'MiniDumpWithThreadInfo': undeclared identifier

出了什么问题?

1 个答案:

答案 0 :(得分:3)

您必须在<windows.h>之前加入<DbgHelp.h>,如果项目使用"Stdafx.h",则必须先包含#include "stdafx.h" #include <windows.h> #include <Dbghelp.h> 。以下是正确的顺序:

import UIKit

extension CAGradientLayer {

    func stopwatchColour() -> CAGradientLayer {

        let topColour = UIColor(red: (11/255.0), green: (128/255.0), blue: (105/255.0), alpha: 1)
        let bottomColour = UIColor(red: (39/255.0), green: (90/255.0), blue: (78/255.0), alpha: 1)
        let gradientColours: [CGColor] = [topColour.cgColor, bottomColour.cgColor]
        let gradientLocations: [Float] = [0.0, 1.0]
        let gradientLayer: CAGradientLayer = CAGradientLayer()
        gradientLayer.colors = gradientColours
        gradientLayer.locations = gradientLocations as [NSNumber]
        return gradientLayer
    }
}

还要确保将DbgHelp.lib链接到“项目设置”&gt;链接器&gt;输入&gt; '附加依赖'。