dimanche 21 novembre 2021

Wy can't I cast a statically cast Lambda as a TIMEPROC Function pointer in a settimer?

I coded this multiple times. But it doesn't even seem to work in a simple console hello word application. Is hWND the one to blame, lambda, or the casting of the lambda?

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include "Windows.h"
int main()
{
    SetTimer
    (
        GetConsoleWindow(), UINT_PTR(0), 1000, (TIMERPROC)static_cast<void(*)()>([]()
        {
        printf("Hello World!");
        })
    );
    return 0;
}

It doesn't give me warnings.

Aucun commentaire:

Enregistrer un commentaire