如何使用 Visual C++ 工具集报告问题How to Report a Problem with the Visual C++ Toolset

使用 Visual C++ 编译器、链接器或其他工具时如果遇到问题,请告知我们。If you encounter problems with the Visual C++ compiler, linker, or other tools, we want to know about them.

最好是向我们发送报告,在报告中说明你所遇到的问题、如何生成程序的详细信息,以及相关代码(以便我们在自己的计算机上重现该问题)。The best way to let us know about a problem is to send us a report that includes a description of the problem you've encountered, details about how you're building your program, and some code we can use to reproduce the problem on our own machines. 通过这些信息,我们可以快速验证问题是否存在于本地环境,判断它是否会影响其他版本的编译器,并诊断其原因。This information lets us quickly verify that the problem exists and is not local to your environment, determine whether it affects other versions of the compiler, and to diagnose its cause.

在本文档中,你将了解到In this document, you'll read about

无论对我们,还是对和你一样的其他开发者而言,你的报告都十分重要。Your reports are important to us and to other developers like you. 谢谢你帮助我们改进 Visual C++!Thank you for helping us improve Visual C++!

如何准备报告How to prepare your report

创建高质量报告至关重要,因为一旦缺少完整信息,我们将难以在计算机上重现你所遇到的问题。Creating a high-quality report is important because its very difficult to reproduce the problem you encountered on our own machines without complete information. 报告的质量越高,我们重新创建和诊断问题的效率就越高。The better your report is, the more effectively we are able recreate and diagnose the problem.

报告中应至少包括At a minimum, your report should contain

  • 正在使用的工具集的完整版本信息。The full version information of the toolset you're using.

  • 用于生成代码的完整 cl.exe 命令行。The full cl.exe command line used to build your code.

  • 对所遇到问题的详细描述。A detailed description of the problem you encountered.

  • 一份“重现” - 用于演示问题的源代码。A 'repro'—source code that demonstrates the problem.

阅读以继续了解更多关于我们所需的特定信息,以及在何处可以找到它们的详细信息。Read on to learn more about the specific information we need and where you can find it.

工具集版本The toolset version

需要你正在使用的工具集的完整版本信息,以便在我们的计算机上针对相同工具集测试你的重现。We need the full version information of the toolset you're using so that we can test your repro against the same toolset on our machines. 如果我们可以重现此问题,我们还可以将此信息作为起点,调查哪些版本的工具集存在同样的问题。If we can reproduce the problem, this information also gives us a starting point to investigate which other versions of the toolset exhibit the same problem.

报告你正在使用的编译器的完整版本To report the full version of the compiler you're using

  1. 在键盘上按 Windows 徽标键,然后开始键入 Developer Command PromptPress the Windows key on your keyboard and begin typing Developer Command Prompt.

  2. 在匹配列表中,选择“开发人员命令提示符”版本,该版本与你正使用的 Visual Studio 版本相匹配。Choose the Developer Command Prompt version that matches the version of Visual Studio you're using when it appears in the list of matches.

  3. 在“开发人员命令提示”控制台中,输入命令 cl /Bv /CLRIn the Developer Command Prompt console, enter the command cl /Bv /CLR.

该输出应与以下类似:The output should look similar to this:

C:\Compiler>cl /Bv /CLR
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.40209
for Microsoft (R) .NET Framework version 4.00.30319.34014
Copyright (C) Microsoft Corporation.  All rights reserved.

Compiler Passes:
 C:\WinCComp\binaries.x86chk\bin\i386\cl.exe:        Version 18.00.40209.0
 C:\WinCComp\binaries.x86chk\bin\i386\c1.dll:        Version 18.00.40209.0
 C:\WinCComp\binaries.x86chk\bin\i386\c1xx.dll:      Version 18.00.40209.0
 C:\WinCComp\binaries.x86chk\bin\i386\c2.dll:        Version 18.00.40209.0
 C:\WinCComp\binaries.x86chk\bin\i386\link.exe:      Version 12.00.40209.0
 C:\WinCComp\binaries.x86chk\bin\i386\mspdb120.dll:  Version 12.00.40209.0
 C:\WinCComp\binaries.x86chk\bin\i386\1033\clui.dll: Version 18.00.40209.0
 Common Language Runtime:                            Version  4.00.30319.34014

cl : Command line error D8003 : missing source filename

将整个输出复制并粘贴到报告。Copy and paste the entire output into your report.

命令行The command line

需要用于生成代码的完整命令行(cl.exe 和其参数),以便我们以完全相同的方式在计算机上生成它。We need the full command line (cl.exe and its arguments) used to build your code so that we can build it in exactly the same way on our machines. 这一点很重要,因为你所遇到的问题可能仅在使用某一特定参数或参数组合生成时才存在。This is important because the problem you've encountered might only exist when building with a certain argument or combination of arguments.

此信息位于遇到问题后立即出现的生成日志中,建议在该位置查找。The best place to find this information is in the build log immediately after experiencing the problem. 这可确保命令行包含完全相同的参数,从而有可能帮助解决问题。This ensures that the command line contains exactly the same arguments that might be contributing to the problem.

报告命令行的内容To report the contents of the command line

  1. 找到并打开 CL.command.1.tlog 文件。Locate the CL.command.1.tlog file and open it. 默认情况下,此文件位于 \...\Visual Studio Version\Projects\SolutionName\ProjectName\Config\ProjectName.tlog\CL.command.1.tlog。By default, this file is located at \...\Visual Studio Version\Projects\SolutionName\ProjectName\Config\ProjectName.tlog\CL.command.1.tlog.

    可在此文件中找到源代码文件的名称,其后是用于编译它们的命令行参数(每个分占一行)。Inside this file, you'll find the names of source code files followed by the command line arguments used to compile them, each on separate lines.

  2. 找到包含源代码文件名称的行(问题发生之处);其下方的行包含相应的 cl.exe 命令及其参数。Locate the line that contains the name of the source code file where the problem occurs; the line below it contains the corresponding cl.exe command and its arguments.

将整个命令行复制并粘贴到报告。Copy and paste the entire command line into your report.

问题说明A description of the problem

我们需要一份有关你所遇到问题的详细说明,以验证是否可以在我们的计算机上观察到相同的效果;有时,它还有助于使我们了解你所尝试完成的内容,以及你希望看到的结果。We need a detailed description of the problem you've encountered so that we can verify that we see the same effect on our machines; its also sometimes useful for us to know what you were trying to accomplish, and what you expected to happen.

请提供由工具集提供的精确错误消息,并简短说明你所尝试完成的内容,以帮助我们了解你的重现代码,并提供任何其他可能有助于诊断你所遇到的问题的详细信息(例如你可能已经发现的任何解决方法)。Please provide the precise error messages given by the toolset, a brief description of what you were trying to accomplish to help us understand your repro code, and any other details that might help us diagnose the problem you experienced, such as any work-arounds you might have found. 避免在报表的其他部分出现重复信息。Avoid repeating information found elsewhere in your report.

重现The repro

我们需要一份重现,一个演示你所遇到的问题的自包含源代码示例,以便在我们的计算机上重现该错误。We need a repro, a self-contained source code example that demonstrates the problem you've encountered, so that we can reproduce the error on our machines. 所遇问题的类型决定了应在报告中添加的重现类型。The kind of problem you encounter will determine what kind of repro you should include in your report. 如果无法正确重新,我们将无法进行调查。Without an appropriate repro, we have nothing to investigate.

简短的自包含重现可以直接包含在报告文本中,但较大的源代码重现应附加到报告中。Short, self-contained repros can be directly included in your report text, but larger source code repros should be attached to the report. 对于无法缩小到单个源代码文件的重现,应将包含所有文件的目录以压缩为 .zip 文件或类似文件的方式打包,并附加到报告。Repros that can't be reduced to a single source code file should be packaged by compressing a directory containing all the files into a .zip file or similar and attached to the report. 任何其他特定方案的详细信息也应包含在报告文本中,而非源代码中。Any additional scenario-specific details should always be included in the report text, never in source code.

你所能提供的最佳重现是最小重现。The best kind of repro you can provide us is a minimal repro. 这是一种单独的自包含源代码文件(缺少对用户标头的引用),仅包含演示问题所需的代码。This is a single, self-contained source code file (without references to user headers) that contains just enough code to demonstrate the problem. 如果你能提供这种形式的重现,请将源代码文件直接附加到报告;这就是我们所需要的。If you can provide a repro in this form, just attach the source code file to your report; its all we need.

如果无法在缺少依赖项的情况下将问题压缩为最小重现,请参阅下列部分,判断应在报告中添加何种类型的重现。If you can't condense the problem to a minimal repro without dependencies, refer to the following sections to determine the kind of repro you should include in your report.

前端(分析程序)故障Frontend (parser) crash

前端故障发生在编译器的分析阶段。Frontend crashes occur during the parsing phase of the compiler. 通常情况下,编译器会发出错误 C1001,并引用错误发生处的源代码文件和行号;它还会常常提及文件 msc1.cpp,你可忽略此详细信息。Typically, the compiler will emit Fatal Error C1001 and reference the source code file and line number on which the error occurred; it will often mention a file msc1.cpp, but you can ignore this detail.

对于这种类型的故障,请提供预处理过的重现For this kind of crash, please provide a Preprocessed Repro.

下面是此种故障类型的示例编译器输出:Here's example compiler output for this kind of crash:

SandBoxHost.cpp
d:\o\dev\search\foundation\common\tools\sandbox\managed\managed.h(929):
        fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'msc1.cpp', line 1369)
To work around this problem, try simplifying or changing the program near the
        locations listed above.
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
d:\o\dev\search\foundation\common\tools\sandbox\managed\managed.h(929):
        note: This diagnostic occurred in the compiler generated function
        'void Microsoft::Ceres::Common::Tools::Sandbox::SandBoxedProcess::Dispose(bool)'
Internal Compiler Error in d:\o\dev\otools\bin\x64\cl.exe.  You will be prompted
        to send an error report to Microsoft later.
INTERNAL COMPILER ERROR in 'd:\o\dev\otools\bin\x64\cl.exe'
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information

后端(代码生成)故障Backend (code generation) crash

后端故障发生在编译器的代码生成阶段。Backend crashes occur during the code generation phase of the compiler. 通常情况下,编译器会发出错误 C1001,并可能不会引用与问题相关的源代码文件和行号;它通常会提及文件 compiler\utc\src\p2\main.c,你可忽略此详细信息。Typically, the compiler will emit Fatal Error C1001, and might not reference the source code file and line number associated with the problem; it will often mention a file compiler\utc\src\p2\main.c, but you can ignore this detail.

对于这种类型的故障,如果使用的是链接时间代码生成 (LTCG),请提供链接重现,如果不是,请提供预处理过的重现For this kind of crash please provide a Link Repro if you are using Link-Time Code Generation (LTCG) or a Preprocessed Repro if not. LTCG 由 cl.exe 的 /GL 命令行参数启用。LTGC is enabled by the /GL command-line argument to cl.exe.

下面是此种故障类型的示例编译器输出,其中使用 LTCG。Here's example compiler output for this kind of crash in which LTCG is not used. 如果编译器输出与此类似,请提供预处理过的重现If your compiler output looks like this you should provide a Preprocessed Repro.

repro.cpp
\\officefile\public\tadg\vc14\comperror\repro.cpp(13) : fatal error C1001:
        An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 230)
To work around this problem, try simplifying or changing the program near the
        locations listed above.
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
INTERNAL COMPILER ERROR in
        'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe'
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information

如果以内部编译器错误开头的行提及 link.exe,而不是 cl.exe 并且已启用 LTCG,请提供链接重现If the line that begins with INTERNAL COMPILER ERROR mentions link.exe, rather than cl.exe, LTCG was enabled and you should provide a Link Repro. 如果不清楚是否因编译器错误消息而启用了 LTCG,可能需要检查你在 /GL 命令行参数的上一步中,从生成日志复制的命令行参数。If its not clear whether LTCG was enabled from the compiler error message, you may need to examine the command line arguments that you copied from your build log in a previous step for the /GL command-line argument.

链接器故障Linker crash

链接器故障发生在链接阶段,在编译器已运行之后。Linker crashes occur during the linking phase, after the compiler has run. 通常情况下,链接器将发出链接器工具错误 LNK1000Typically, the linker will emit Linker Tools Error LNK1000.

备注

如果输出提及 C1001 或涉及链接时间代码生成,请参阅后端(代码生成)故障,了解更多信息。If the output mentions C1001 or involves Link-Time Code Generation, refer to Backend (code generation) crash instead for more information.

对于这种类型的故障,请提供链接重现For this kind of crash, please provide a Link Repro.

下面是此种故障类型的示例编译器输出。Here's example compiler output for this kind of crash.

z:\foo.obj : error LNK1000: Internal error during IMAGE::Pass2

  Version 14.00.22816.0

  ExceptionCode            = C0000005
  ExceptionFlags           = 00000000
  ExceptionAddress         = 00007FF73C9ED0E6 (00007FF73C9E0000)
        "z:\tools\bin\x64\link.exe"
  NumberParameters         = 00000002
  ExceptionInformation[ 0] = 0000000000000000
  ExceptionInformation[ 1] = FFFFFFFFFFFFFFFF

CONTEXT:

  Rax    = 0000000000000400  R8     = 0000000000000000
  Rbx    = 000000655DF82580  R9     = 00007FF840D2E490
  Rcx    = 005C006B006F006F  R10    = 000000655F97E690
  Rdx    = 000000655F97E270  R11    = 0000000000000400
  Rsp    = 000000655F97E248  R12    = 0000000000000000
  Rbp    = 000000655F97EFB0  E13    = 0000000000000000
  Rsi    = 000000655DF82580  R14    = 000000655F97F390
  Rdi    = 0000000000000000  R15    = 0000000000000000
  Rip    = 00007FF73C9ED0E6  EFlags = 0000000000010206
  SegCs  = 0000000000000033  SegDs  = 000000000000002B
  SegSs  = 000000000000002B  SegEs  = 000000000000002B
  SegFs  = 0000000000000053  SegGs  = 000000000000002B
  Dr0    = 0000000000000000  Dr3    = 0000000000000000
  Dr1    = 0000000000000000  Dr6    = 0000000000000000
  Dr2    = 0000000000000000  Dr7    = 0000000000000000

如果启用增量链接,且仅在进行初始链接之后才发生故障(也就是说,仅在第一个完整链接之后才发生,随后的增量链接都基于该完整链接),请提供对象 (.obj) 和库 (.lib) 文件的副本,它们对应于初始链接完成后被修改的源文件。If incremental linking is enabled and the crash occurred only after initial linking—that is, only after the first full linking on which subsequent incremental linking is based—please also provide a copy of the object (.obj) and library (.lib) files that correspond to source files that were modified after the initial linking was completed.

错误代码生成Bad code generation

错误代码生成很少发生,但当编译器错误地生成不正确的代码时,它将发生,并造成应用程序在运行时(而非在编译时检测此问题时)出现故障。Bad code generation is rare, but occurs when the compiler mistakenly generates incorrect code that will cause your application to crash at runtime rather than detecting this problem at compile-time. 如果你认为所遇到的问题会导致错误代码生成,请将报告同样视为后端(代码生成)故障If you believe the problem you are experiencing results in bad code generation, treat your report the same as a Backend (code generation) crash.

对于这种类型的故障,如果使用的是链接时间代码生成 (LTCG),请提供链接重现,如果不是,请提供预处理过的重现For this kind of crash please provide a Link Repro if you are using Link-Time Code Generation (LTCG) or a Preprocessed Repro if not. LTCG 由 cl.exe 的 /GL 命令行参数启用。LTGC is enabled by the /GL command-line argument to cl.exe.

发送报告的方式Ways to send your report

向我们提交报告的方式有多种。There are several ways to get your report to us. 可以使用 Visual Studio 内置的报告问题工具,或者给我们发送电子邮件。You can use Visual Studio's built-in Report a Problem Tool, or email us. 提交报告的最佳方式取决于你遇到的问题类型、希望与调查报告的工程师互动的方式、以及是要跟踪其进度还是与社区共享报告。The best choice for your report depends on the kind of problem you've encountered, how you want to interact with the engineers who will investigate your report, and whether you'd like to track its progress or share your report with the community.

备注

无论以何种方式提交报告,Microsoft 都尊重你的隐私。Regardless of how you submit your report, Microsoft respects your privacy. 有关我们如何处理你发送给我们的数据的信息,请参阅 Microsoft Visual Studio 产品系列隐私声明For information about how we treat the data that you send us, see the Microsoft Visual Studio Product Family Privacy Statement.

发送电子邮件Send an Email

发送电子邮件是将报告直接发送到 Visual C++ 团队的另一种方式;可以通过 compilercrash@microsoft.com 与我们联系。Email is another way to send your report directly to the Visual C++ team; you can reach us at compilercrash@microsoft.com.

如果选择通过电子邮件发送报告,可采用以下模板作为电子邮件的正文。If you choose to send your report by email, you can use the following template as the body of your email message. 如果电子邮件正文中未包括源代码或其他文件,请不要忘记将其附加在电子邮件中。Don't forget to attach source code or other files if you aren't including that information in the email body.

To: compilercrash@microsoft.com
Subject: Visual C++ Error Report
-----

Compiler version:

CL.EXE command line:

Problem description:

Source code and repro steps:

使用“报告问题”工具Use the Report a Problem tool

Visual Studio 用户可以使用 Visual Studio 中的“报告问题”工具报告各种问题,操作简单,只需几次单击即可完成。The Report a Problem tool in Visual Studio is a way for Visual Studio users to report a variety of problems with just a few clicks. 该工具提供了一个简单的表单,你可以使用它来指定所遇问题的详细信息,然后在不离开 IED 的情况下提交报告。It provides a simple form that you can use to specify detailed information about the problem you've encountered and then submit your report without ever leaving the IDE.

对于本文中所讨论的工具集问题而言,通过“报告问题”工具提交报告并不常见,然而,如果它适合你,那么也不失为一个选择。Reporting your problem through the Report a Problem tool is unusual for the kinds of toolset problems discussed in this document; nevertheless, its an option you can choose if it suites your preferences.

提示

对于可能在 Visual Studio 中遇到的、与工具集无关的问题(例如 UI 问题、损坏的 IDE 功能或常规故障),“报告问题”工具可能是最佳之选,因为它具有屏幕截图功能,可以记录导致问题的 UI 操作。For other kinds of problems you might encounter in Visual Studio that are not related to the toolset (For example, UI issues, broken IDE functionality, or general crashes), the Report a Problem tool can be an especially good choice due to its screenshot capabilities and its ability to record UI actions that lead to the problem you've encountered. 请勿以发送电子邮件至 compilercrash@microsoft.com 的方式报告其他类型的错误。You should never report these other kinds of errors by sending email to compilercrash@microsoft.com.

生成重现Generate a repro

重现是一个完整的自包含代码示例,用于演示所报告的问题。A repro is a complete, self-contained code example, that demonstrates the problem you're reporting. 重现并非一个代码片段 - 它必须是生成和运行的完整示例(你所报告的问题产生的错误除外)。A repro is not a code snippet—it must be a complete example that builds and runs (or would, except for the errors produced by the problem you're reporting). 它应包含全部必需的 #include 指令,即使对标准标头亦是如此。It should contain all the necessary #include directives, even for the standard headers.

此外,好的重新应是Furthermore, a good repro is

  • 最小的。Minimal. 重现应尽可能最小,但仍能准确演示所遇到的问题。Repros should be as small as possible while still demonstrating exactly the problem you encountered. 重现无需复杂或真实 - 以简单扼要的重现为佳。Repros do not need to be complex or realistic—simple, to-the-point repros are better. 它们无需包含可运行的计数器示例代码,但在用于说明时亦可包含;只有导致问题的示例代码才是必需的。They do not need to include counter-examples of code that works, but may if it is illustrative; only example code that causes the issue is necessary.

  • 自包含。Self-Contained. 重现应避免不需要的依赖项。Repros should avoid unnecessary dependencies. 如果无需第三方库就可重现,请直接重现。If you can reproduce the problem without third-party libraries, please do so. 如果无需任何库代码就可重现(可使用 std::outprintf()),请直接重现。If you can reproduce the problem without any library code (std::out, printf() are ok), please do so. 尽可能减少我们需要考虑的有利于解决问题的代码量,这对我们而言极为有用。Reducing the amount of code we have to consider as a possible contributor to the problem is enormously helpful to us.

  • 针对最新版本的编译器。Against the latest compiler version. 重现应尽可能使用最新版本的工具集。Repros should use the latest version of the toolset whenever possible. 在旧版本的工具集中可能仍会遇到的问题,很有可能已在新版本中得到修复。Problems you might still encounter in older versions of the toolset have very often been fixed in newer versions.

  • 如果相关,请在其他编译器中进行检查Checked against other compilers, if relevant. 在可能的情况下,涉及可移植 C++ 代码的重现,应在其他编译器中验证行为。Repros that involve portable C++ code should verify behavior against other compilers if possible.

    此步骤有助于判断代码是正确的(MSVC 否定 Clang 和 GCC 时)还是错误的(MSVC、Clang 和 GCC 一致认为代码产生了错误时)。This step helps to determine whether your code is correct, as when MSVC disagrees with Clang and GCC, or incorrect, as when MSVC, Clang, and GCC agree that your code produces the error.

以下是生成用于报告不同类型问题的各种重现的说明。Below are instructions for generating the various kinds of repros you'll use to report different kinds of problems.

预处理过的重现Preprocessed repros

预处理过的重现是用于说明问题的单个源文件,它从 C 预处理器的输出中通过处理原始源文件而生成。A preprocessed repro is a single source file that demonstrates a problem and has been generated from the output of the C preprocessor by processing the original source file. 此进程内联包含标头,以删除其他源和头文件中的依赖项、宏、#ifdefs 以及其他可能依赖本地化环境的预处理器命令。This process inlines included headers to remove dependencies on additional source and header files, and also resolves macros, #ifdefs, and other preprocessor commands that could depend your local environment.

备注

请注意,对于在标准库实现中可能导致 Bug 的问题而言,预处理过的重现可能是最不方便的,因为我们会经常替换最新、正在进行中的实现,以确定我们是否已修复问题。Note that preprocessed repros are least convenient for problems that might be the result of bugs in our standard library implementation because we will often want to substitute our latest, in-progress implementation to see whether we've already fixed the problem. 在这种情况下请勿预处理重现,此外,如果无法将问题减少到单个源文件,请将代码打包为 .zip 文件或其他类似文件,或考虑使用 IDE 项目重现(请参阅下方的其他重现)。In this case, don't preprocess the repro, and if you can't reduce the problem to a single source file, package your code into a .zip file or similar, or consider using an IDE project repro (see Other Repros below).

预处理源代码文件To preprocess a source code file

  1. 在键盘上按 Windows 徽标键,然后开始键入 Developer Command PromptPress the Windows key on your keyboard and begin typing Developer Command Prompt.

  2. 在匹配列表中,选择“开发人员命令提示符”版本,该版本与你正使用的 Visual Studio 版本相匹配。Choose the Developer Command Prompt version that matches the version of Visual Studio you're using when it appears in the list of matches.

  3. 在“开发人员命令提示”控制台窗口中,输入命令 cl /P argumentsfilename.cppIn the Developer Command Prompt console window, enter the command cl /P argumentsfilename.cpp.

如果已有预处理过的文件(这里是指 filename.i),使用预处理过的文件来确保问题仍然可被重现,是一个很不错的办法。After you have the preprocessed file (now filename.i), its a good idea to make sure that the problem still repros using the preprocessed file. 可使用 /TP 命令行参数告知 cl.exe 跳过预处理器步骤,并尝试像往常一样编译。You can use the /TP command line argument to tell cl.exe to skip the preprocessor step and attempt to compile as usual.

确认仍可以通过预处理过的文件来重现错误To confirm that the error still repros with the preprocessed file

  1. 在键盘上按 Windows 徽标键,然后开始键入 Developer Command PromptPress the Windows key on your keyboard and begin typing Developer Command Prompt.

  2. 在匹配列表中,选择“开发人员命令提示符”版本,该版本与你正使用的 Visual Studio 版本相匹配。Choose the Developer Command Prompt version that matches the version of Visual Studio you're using when it appears in the list of matches.

  3. 在“开发人员命令提示”控制台窗口中,输入命令 cl arguments /TP filename.iIn the Developer Command Prompt console window, enter the command cl arguments /TP filename.i.

  4. 确认该问题可被重现。Confirm that the problem is reproduced.

最后,将此重现附加到报告。Finally, attach this repro to your report.

链接重现是一个包含生成项目(它们共同说明发生在链接时间的问题)的单独目录,例如涉及链接时间代码生成 (LTCG) 的后端故障,或链接器故障;所包含的生成项目是链接器输入所需的生成项目,因此可以重现问题。A link repro is a single directory containing build artifacts that collectively demonstrate a problem that occurs at link time, such as a backend crash involving Link-Time Code Generation (LTCG), or a linker crash; the included build artifacts are those needed as linker input so that the problem can be reproduced. 使用链接器提供的设备可以轻松创建链接重现。Link repros can be created easily by using facilities provided by the linker.

  1. 打开命令提示符,然后输入命令 mkdir directory,创建链接重现的目录。Open a command prompt and enter the command mkdir directory to create a directory for the link repro.

  2. 将 link_repro 环境变量设置为刚刚创建的目录;输入命令 set link_repro=directorySet the link_repro environment variable to the directory you just created; enter the command set link_repro=directory.

  3. 如果要从 Visual Studio 内部执行生成,请通过输入命令 devenv 从命令提示符处启动它。If you want to perform the build from inside Visual Studio, launch it from the command prompt by entering the command devenv. 这可确保 link_repro 环境变量的值对 Visual Studio 可见。This ensures that the value of the link_repro environment variable is visible to Visual Studio.

  4. 生成应用程序,并确认预期问题已发生。Build your application, and confirm that the expected problem has occurred.

  5. 如果已在步骤 3 中启动 Visual Studio,现在请将其关闭。Close Visual Studio now if you launched it in step 3.

  6. 清除 link_repro 环境变量;输入命令 set link_repro=Clear the link_repro environment variable; enter the command set link_repro=

最后,通过将整个目录压缩为 .zip 文件或相似文件来打包重现,并将其附加到报告中。Finally, package the repro by compressing the entire directory into a .zip file or similar and attach it to your report.

其他重现Other repros

如果无法将问题减少到单个源文件或预处理过的重现,且此问题无需链接重现,我们可以调查 IDE 项目。If you can't reduce the problem to a single source file or preprocessed repro, and the problem does not require a link repro, we can investigate and IDE project. 项目内的代码应仍保持最小,本文档中的所有指导仍然适用。Code inside the project should still be minimal, and all the guidance from this document still applies.

将重现创建为一个最小的 IDE 项目,再将整个目录结构压缩成 .zip 文件或其他相似文件,并将其附加到报告。Create your repro as a minimal IDE project, then package it by compressing the entire directory structure into a .zip file or similar and attach it to your report.