SergiusTheBest/kmtest

Cannot convert const char [] to PVOID

Closed this issue · 3 comments

wbuck commented

So, I was trying out the unit test framework with some simple tests but I immediately ran into the following compiler error:

'void RtlAssert(PVOID,PVOID,ULONG,PSTR)': cannot convert argument 1 from 'const char [12]' to 'PVOID'

This compiler error was generated from the following:

#include <ntddk.h>
#include "kmtest/kmtest.h"
#include "kmd_utility.hpp"

SCENARIO("Minimum operation")
{
    int x{ 2 };
    int y{ 3 };
    int result{ (kmd::min)(x, y) };
    REQUIRE(2 == result);
}

The same errors occurs when passing the contents of the __FILE__ macro to RtlAssert.

Yes, this is an interesting case. I managed to reproduce it when conformance mode in the compiler is turned on (/permissive- switch). For some reason RtlAssert expects non-constant string (PSTR).

Ok, should be fixed now. Please try it.

wbuck commented

Yeah adding the const_cast's worked. Thank-you