Skip to content

Commit 091596c

Browse files
Update compiler-warning-level-4-c4464.md
@corob-msft proposal. I don't warrant it shouldn't be worded in a better way.
1 parent daa9037 commit 091596c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

docs/error-messages/compiler-warnings/compiler-warning-level-4-c4464.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,28 @@ A `#include` directive has a path that includes a '..' parent directory specifie
1313

1414
## Remarks
1515

16-
Starting in Visual Studio 2015 Update 1, the compiler can detect an include directive that contains a '..' path segment and issue a warning, if enabled. Code written in this way is usually intended to include headers that exist outside of the project by incorrectly using project-relative paths. This creates a risk that the program could be compiled by including a different source file than the programmer intends, or that these relative paths would not be portable to other build environments. Although there is no specific warning for it, we also recommend that you do not use a parent directory path segment to specify your project include directories.
16+
Starting in Visual Studio 2015 Update 1, the compiler can detect an include directive that contains a '..' path segment and issue a warning, if enabled. Code written in this way is usually intended to include headers that exist outside of the project by incorrectly using project-relative paths. This creates a risk that the program could be compiled by including a different source file than the programmer intends, or that these relative paths would not be portable to other build environments. Although there is no specific warning for it, we also recommend that you do not use a parent directory path segment when specifying your project include directories via the /I command-line option to the compiler; the INCLUDE environment variable; or the Project Includes settings in Visual Studio.
1717

1818
This warning is new in Visual Studio 2015 Update 1, and is off by default. Use [/Wall](../../build/reference/compiler-option-warning-level.md) to enable all warnings that are off by default, or __/w__*n*__4464__ to enable C4464 as a level *n* warning. For more information, see [Compiler Warnings That Are Off By Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md). For information on how to disable warnings by compiler version, see [Compiler warnings by compiler version](compiler-warnings-by-compiler-version.md).
1919

2020
## Example
2121

2222
Source code files that use '..' path segments can trigger this warning when the **/Wall** option is specified:
2323

24+
Given this code layout:
2425
```cpp
26+
// proj\headers\C4426.h
27+
// some header stuff
28+
```
29+
```cpp
30+
// proj/src\a.cpp
2531
#include "..\headers\C4426.h" // emits warning C4464
2632

27-
// To fix this issue, specify only the header file name, and add
28-
// the absolute path to 'headers\' to your project's include directories
29-
#include "C4426.h"
33+
// To fix this issue, specify only the header file name, and add either
34+
// the parent path of 'headers\' (that is, proj) to your project's include directories,
35+
// or add the absolute path to the "headers" folder.
36+
// Example 1: /Ic:\proj
37+
#include "headers\C4426.h" // correct
38+
// Example 2: /Ic:\proj\headers
39+
#include "C4426.h" // also correct
3040
```

0 commit comments

Comments
 (0)