Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


C++20 and WDF

ChandraTutikaChandraTutika Member Posts: 13

Hi,
I am facing following errors in all the source files when trying to compile SensorsComboDriver for C++20.
1>C:\Windows-driver-samples\sensors\SensorsComboDriver\Clients.h(162,1): error C2440: 'initializing': cannot convert from 'const char [12]' to 'PCHAR'
1>C:\Windows-driver-samples\sensors\SensorsComboDriver\Clients.h(162,1): message : Conversion from string literal loses const qualifier (see /Zc:strictStrings)

Here is what I have tried doing:

  • Open SensorsComboDriver from windows-driver-samples.
  • Successfully built the project.
  • Now change the C++ language standard from default to C++20.
  • Observed the above issues.

Looking at the other OSR posts, I got to know that C++20 is supported in KMDF except STLs and exceptions.
In that case, I was wondering why I am getting the above errors.
Are there any other unsupported features of C++20 that are causing the above issues?

Thanks in advance for the help.
Chandra

Comments

  • Phil_BarilaPhil_Barila Member - All Emails Posts: 169

    PCHAR is not const. Not sure whether PCCHAR is a thing, but the const -> non-const conversion is why it's failing.

  • ChandraTutikaChandraTutika Member Posts: 13

    Agreed. But the issue happens only with C++20.
    The issue is with WDF_DECLARE_CONTEXT_TYPE_WITH_NAME which is a standard WDF macro.
    That's why I am concerned if C++20 is supported with WDF.

  • ChandraTutikaChandraTutika Member Posts: 13

    Found out the solution for the problem.

    Right click on the project -> Properties -> C/C++ -> Command Line -> Add "/Zc:strictStrings- " to the Additional Options.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,718

    That's a great hint. I appreciate the followup.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • AliyaaiAliyaai Member Posts: 2

    @ChandraTutika said:
    Agreed. But the issue happens only with C++20.
    The issue is with WDF_DECLARE_CONTEXT_TYPE_WITH_NAME which is a standard WDF macro.
    That's why I am concerned if C++20 is supported with WDF.

    Hi guys
    It's crucial to check whether C++20 is fully supported by WDF, particularly in light of the fact that the problem only affects the WDF macro WDF_DECLARE_CONTEXT_TYPE_WITH_NAME.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 13-17 May 2024 Live, Online
Developing Minifilters 1-5 Apr 2024 Live, Online
Internals & Software Drivers 11-15 Mar 2024 Live, Online
Writing WDF Drivers 26 Feb - 1 Mar 2024 Live, Online