unreferenced formal parameter



  • Hi why take this warnings. Message of warnings:
    C:\Users\moh\Desktop\Demonio_3.0_src (1)\Demonio_3.0_src\src\servidor\main.cpp:29: warning: C4100: 'hPrevInstance' : unreferenced formal parameter

    Code:

    int WINAPI WinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPSTR lpCmdLine,
                       int nCmdShow)
    {
    }
    

    I think because i need to include some reference???

    [Moved to C++ Gurus ~kshegunov]


  • Qt Champions 2016

    This is the standard warning for when you declare a function parameter, but never use it. You can "fix" this by either not giving the parameter a name, or by using Q_UNUSED to suppress the warning by explicitly marking the parameter as unused. E.g:

    int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) //< Not using any of the parameters
    {
    }
    

    or

    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    {
        Q_UNUSED(hPrevInstance); //< We are not going to use that parameter.
    }
    


  • sorry i forget include this. i use parameters this is the code:
    #include <QApplication>
    #include "mainwindow.h"
    #include <Windows.h>
    #ifndef Q_WS_X11
    #include <QtPlugin>
    #endif

    #ifdef _MSC_VER
    int WINAPI WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow)
    {
    int argc = 0;
    char *argv[1];
    #else
    int main(int argc, char *argv[])
    {
    #endif
    QApplication a(argc, argv);
    MainWindow w;
    return a.exec();
    }


  • Lifetime Qt Champion

    Hi,

    And again: why are you writing your main like that ? There's no need.


  • Qt Champions 2016

    You should listen to what @SGaist's been saying in your other thread and not use WinMain at all, much less the preprocessor. Just create an ordinary C++ program and call the QApplication::exec function. That's all there's to it - no preprocessor magic, no WINAPI fossils:

    #include <QApplication>
    #include "mainwindow.h"
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        MainWindow w;
        w.show();
    
        return a.exec();
    }
    


  • i am trying to record my keyboard and mouse with winapi
    https://msdn.microsoft.com/en-us/library/windows/desktop/ms644990(v=vs.85).aspx


  • Qt Champions 2016

    @RIVOPICO said in unreferenced formal parameter:

    i am trying to record my keyboard and mouse with winapi

    If you mean to do that in your program, then there's a Qt way. If you mean to do that globally for the whole OS, don't. Hooks are a bad idea and are in the API mostly to facilitate debugging (or variants thereof). It can slow your system to a crawl.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.