0

Does the MSVC support C++20 modules for Windows driver projects ?

I enabled C++20 and compiled project, but I taked error (C3474 could not open file DriverModule.ifc). I tried to added path in "[Additional Module dependecies]: $(ProjectDir)DriverModule.ifc", but it wasn't fixing error.

DriverModule.ixx

export module DriverModule;

export int calculate(int x);

DriverModule.cpp

module DriverModule;

int calculate(int x)
{
    return x + 10;
}

EntryPoint.cpp

#include <wdm.h>
import DriverModule;

extern "C" NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath);

NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
    UNREFERENCED_PARAMETER(DriverObject);
    UNREFERENCED_PARAMETER(RegistryPath);
    int b = calculate(28);
    KdPrint(("%d", b));
    return STATUS_SUCCESS;
}
  • According to https://en.cppreference.com/w/cpp/compiler_support/20, Modules were added in 16.8, I don't know if that extends to windows drivers or not, or if the issue is with something else entirely, as I've not used them. Have you tried similar code on a non-windows driver project? Say, just using a simple console program? – ChrisMM Jun 16 '22 at 19:15
  • The driver stuff, quite justifiably, tends to be more conservative. I wouldn't be surprised if Microsoft holds new features back until they have good numbers proving they aren't releasing something that easily craters PCs. – user4581301 Jun 16 '22 at 19:23
  • @ChrisMM Yes, I used a simple console project and the modules work successfully. – Magistr_Y0da Jun 16 '22 at 19:43

0 Answers0