Skip to content

Commit 2e2e4f2

Browse files
author
Colin Robertson
committed
Updates for /permissive in 15.8
1 parent 0d7f9b7 commit 2e2e4f2

1 file changed

Lines changed: 96 additions & 52 deletions

File tree

‎docs/build/reference/permissive-standards-conformance.md‎

Lines changed: 96 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ class CFoo : public ICustom
187187

188188
```cpp
189189
// Fix for example 2
190-
// First, create the *.idl file. The vc140.idl generated file can be
191-
// used to automatically obtain a *.idl file for the interfaces with
192-
// annotation. Second, add a midl step to your build system to make
193-
// sure that the C++ interface definitions are outputted.
194-
// Last, adjust your existing code to use ATL directly as shown in
190+
// First, create the *.idl file. The vc140.idl generated file can be
191+
// used to automatically obtain a *.idl file for the interfaces with
192+
// annotation. Second, add a midl step to your build system to make
193+
// sure that the C++ interface definitions are outputted.
194+
// Last, adjust your existing code to use ATL directly as shown in
195195
// the atl implementation section.
196196

197197
-- IDL FILE--
@@ -271,7 +271,7 @@ struct MyString
271271

272272
extern bool cond;
273273

274-
MyString s;
274+
MyString s;
275275
// Using /std:c++14, /permissive- or /Zc:ternary behavior
276276
// is to prefer MyString("A") over (const char*)s
277277
// but under /std:c++17 this line causes error C2445:
@@ -294,13 +294,13 @@ void myassert(const char* text, const char* file, int line);
294294
You may also see errors in template metaprogramming, where conditional operator result types may change under **/Zc:ternary** and **/permissive-**. One way to resolve this issue is to use [std::remove_reference](../../standard-library/remove-reference-class.md) on the resulting type.
295295

296296
```cpp
297-
// Example 4: different result types
297+
// Example 4: different result types
298298
extern bool cond;
299299
extern int count;
300-
char a = 'A';
301-
const char b = 'B';
302-
decltype(auto) x = cond ? a : b; // char without, const char& with /Zc:ternary
303-
const char (&z)[2] = count > 3 ? "A" : "B"; // const char* without /Zc:ternary
300+
char a = 'A';
301+
const char b = 'B';
302+
decltype(auto) x = cond ? a : b; // char without, const char& with /Zc:ternary
303+
const char (&z)[2] = count > 3 ? "A" : "B"; // const char* without /Zc:ternary
304304
```
305305
306306
#### Two-phase name look up (partial)
@@ -335,64 +335,108 @@ int main()
335335

336336
The **/permissive-** option is too strict for versions of the Windows Kits before Windows Fall Creators Update SDK (10.0.16299.0), or the Windows Driver Kit (WDK) version 1709. We recommend you update to the latest versions of the Windows Kits in order to use **/permissive-** in your Windows or device driver code.
337337

338-
Certain header files in the Windows Fall Creators Update SDK (10.0.16299.0), or the Windows Driver Kit (WDK) 1709, still have issues that make them incompatible with use of **/permissive-**. To work around these issues, we recommend you restrict the use of these headers to only those source code files that require them, and remove the **/permissive-** option when you compile those specific source code files. The following issues are specific to the Windows Fall Creators Update SDK (10.0.16299.0):
338+
Certain header files in the Windows April 2018 Update SDK (10.0.17134.0), the Windows Fall Creators Update SDK (10.0.16299.0), or the Windows Driver Kit (WDK) 1709, still have issues that make them incompatible with use of **/permissive-**. To work around these issues, we recommend you restrict the use of these headers to only those source code files that require them, and remove the **/permissive-** option when you compile those specific source code files.
339339

340-
#### Issue in um\Query.h
340+
These WinRT WRL headers released in the Windows April 2018 Update SDK (10.0.17134.0) are not clean with **/permissive-**. To work around these issues, either do not use **/permissive-**, or use **/permissive-** with **/Zc:twoPhase-** when working with these headers:
341341

342-
When using the **/permissive-** compiler switch, the `tagRESTRICTION` structure does not compile due to the case(RTOr) member 'or'.
342+
- Issues in winrt/wrl/async.h
343343

344-
```cpp
345-
struct tagRESTRICTION
346-
    {
347-
    ULONG rt;
348-
    ULONG weight;
349-
    /* [switch_is][switch_type] */ union _URes
350-
        {
351-
        /* [case()] */ NODERESTRICTION ar;
352-
        /* [case()] */ NODERESTRICTION or; // error C2059: syntax error: '||'
353-
        /* [case()] */ NODERESTRICTION pxr;
354-
        /* [case()] */ VECTORRESTRICTION vr;
355-
        /* [case()] */ NOTRESTRICTION nr;
356-
        /* [case()] */ CONTENTRESTRICTION cr;
357-
        /* [case()] */ NATLANGUAGERESTRICTION nlr;
358-
        /* [case()] */ PROPERTYRESTRICTION pr;
359-
        /* [default] */  /* Empty union arm */
360-
        } res;
361-
    };
362-
```
344+
```Output
345+
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\winrt\wrl\async.h(483): error C3861: 'TraceDelegateAssigned': identifier not found
346+
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\winrt\wrl\async.h(491): error C3861: 'CheckValidStateForDelegateCall': identifier not found
347+
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\winrt\wrl\async.h(509): error C3861: 'TraceProgressNotificationStart': identifier not found
348+
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\winrt\wrl\async.h(513): error C3861: 'TraceProgressNotificationComplete': identifier not found
349+
```
363350

364-
To address this issue, compile files that include Query.h without the **/permissive-** option.
351+
- Issue in winrt/wrl/implements.h
365352

366-
#### Issue in um\cellularapi_oem.h
353+
```Output
354+
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt\wrl\implements.h(2086): error C2039: 'SetStrongReference': is not a member of 'Microsoft::WRL::Details::WeakReferenceImpl'
355+
```
367356

368-
When using the **/permissive-** compiler switch, the forward declaration of `enum UICCDATASTOREACCESSMODE` causes a warning:
357+
These User Mode headers released in the Windows April 2018 Update SDK (10.0.17134.0) are not clean with **/permissive-**. To work around these issues, do not use **/permissive-** when working with these headers:
369358

370-
```cpp
371-
typedef enum UICCDATASTOREACCESSMODE UICCDATASTOREACCESSMODE; // C4471
372-
```
359+
- Issues in um/Tune.h
373360

374-
The forward declaration of unscoped enum is a Microsoft extension. To address this issue, compile files that include cellularapi_oem.h without the **/permissive-** option, or use the [/wd](../../build/reference/compiler-option-warning-level.md) option to silence warning C4471.
361+
```Output
362+
C:\ProgramFiles(x86)\Windows Kits\10\include\10.0.17134.0\um\tune.h(139): error C3861: 'Release': identifier not found
363+
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um\tune.h(559): error C3861: 'Release': identifier not found
364+
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um\tune.h(1240): error C3861: 'Release': identifier not found
365+
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um\tune.h(1240): note: 'Release': function declaration must be available as none of the arguments depend on a template parameter
366+
```
375367

376-
#### Issue in um\omscript.h
368+
- Issue in um/spddkhlp.h
377369

378-
In C++03, a conversion from a string literal to BSTR (which is a typedef to 'wchar_t *') is deprecated but allowed. In C++11, the conversion is no longer allowed.
370+
```Output
371+
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um\spddkhlp.h(759): error C3861: 'pNode': identifier not found
372+
```
379373

380-
```cpp
381-
virtual /* [id] */ HRESULT STDMETHODCALLTYPE setExpression(
382-
/* [in] */ __RPC__in BSTR propname,
383-
/* [in] */ __RPC__in BSTR expression,
384-
/* [in][defaultvalue] */ __RPC__in BSTR language = L"") = 0; // C2440
385-
```
374+
- Issues in um/refptrco.h
375+
376+
```Output
377+
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um\refptrco.h(179): error C2760: syntax error: unexpected token 'identifier', expected 'type specifier'
378+
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um\refptrco.h(342): error C2760: syntax error: unexpected token 'identifier', expected 'type specifier'
379+
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um\refptrco.h(395): error C2760: syntax error: unexpected token 'identifier', expected 'type specifier'
380+
```
381+
382+
These issues are specific to User Mode headers in the Windows Fall Creators Update SDK (10.0.16299.0):
383+
384+
- Issue in um/Query.h
385+
386+
When using the **/permissive-** compiler switch, the `tagRESTRICTION` structure does not compile due to the case(RTOr) member 'or'.
387+
388+
```cpp
389+
struct tagRESTRICTION
390+
{
391+
ULONG rt;
392+
ULONG weight;
393+
/* [switch_is][switch_type] */ union _URes
394+
{
395+
/* [case()] */ NODERESTRICTION ar;
396+
/* [case()] */ NODERESTRICTION or; // error C2059: syntax error: '||'
397+
/* [case()] */ NODERESTRICTION pxr;
398+
/* [case()] */ VECTORRESTRICTION vr;
399+
/* [case()] */ NOTRESTRICTION nr;
400+
/* [case()] */ CONTENTRESTRICTION cr;
401+
/* [case()] */ NATLANGUAGERESTRICTION nlr;
402+
/* [case()] */ PROPERTYRESTRICTION pr;
403+
/* [default] */ /* Empty union arm */
404+
} res;
405+
};
406+
```
407+
408+
To address this issue, compile files that include Query.h without the **/permissive-** option.
409+
410+
- Issue in um/cellularapi_oem.h
411+
412+
When using the **/permissive-** compiler switch, the forward declaration of `enum UICCDATASTOREACCESSMODE` causes a warning:
413+
414+
```cpp
415+
typedef enum UICCDATASTOREACCESSMODE UICCDATASTOREACCESSMODE; // C4471
416+
```
417+
418+
The forward declaration of unscoped enum is a Microsoft extension. To address this issue, compile files that include cellularapi_oem.h without the **/permissive-** option, or use the [/wd](../../build/reference/compiler-option-warning-level.md) option to silence warning C4471.
419+
420+
- Issue in um/omscript.h
421+
422+
In C++03, a conversion from a string literal to BSTR (which is a typedef to 'wchar_t *') is deprecated but allowed. In C++11, the conversion is no longer allowed.
423+
424+
```cpp
425+
virtual /* [id] */ HRESULT STDMETHODCALLTYPE setExpression(
426+
/* [in] */ __RPC__in BSTR propname,
427+
/* [in] */ __RPC__in BSTR expression,
428+
/* [in][defaultvalue] */ __RPC__in BSTR language = L"") = 0; // C2440
429+
```
386430
387-
To address this issue, compile files that include omscript.h without the **/permissive-** option, or use **/Zc:strictStrings-** instead.
431+
To address this issue, compile files that include omscript.h without the **/permissive-** option, or use **/Zc:strictStrings-** instead.
388432
389433
### To set this compiler option in the Visual Studio development environment
390434
391435
In Visual Studio 2017 version 15.5 and later versions, use this procedure:
392436
393437
1. Open your project's **Property Pages** dialog box.
394438
395-
1. Under **Configuration Properties**, expand the **C/C++** folder and choose the **Language** property page.
439+
1. Select the **Configuration Properties** > **C/C++** > **Language** property page.
396440
397441
1. Change the **Conformance mode** property value to **Yes (/permissive-)**. Choose **OK** or **Apply** to save your changes.
398442
@@ -410,5 +454,5 @@ In versions before Visual Studio 2017 version 15.5, use this procedure:
410454
411455
## See also
412456
413-
[Compiler Options](../../build/reference/compiler-options.md)
414-
[Setting Compiler Options](../../build/reference/setting-compiler-options.md)
457+
- [Compiler Options](../../build/reference/compiler-options.md)
458+
- [Setting Compiler Options](../../build/reference/setting-compiler-options.md)

0 commit comments

Comments
 (0)