Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. unreferenced formal parameter
Forum Updated to NodeBB v4.3 + New Features

unreferenced formal parameter

Scheduled Pinned Locked Moved Unsolved C++ Gurus
7 Posts 3 Posters 7.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • RIVOPICOR Offline
    RIVOPICOR Offline
    RIVOPICO
    wrote on last edited by kshegunov
    #1

    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]

    kshegunovK 1 Reply Last reply
    0
    • RIVOPICOR RIVOPICO

      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]

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      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.
      }
      

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      2
      • RIVOPICOR Offline
        RIVOPICOR Offline
        RIVOPICO
        wrote on last edited by
        #3

        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();
        }

        kshegunovK 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • RIVOPICOR RIVOPICO

            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();
            }

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            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();
            }
            

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            1
            • RIVOPICOR Offline
              RIVOPICOR Offline
              RIVOPICO
              wrote on last edited by RIVOPICO
              #6

              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

              kshegunovK 1 Reply Last reply
              0
              • RIVOPICOR RIVOPICO

                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

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #7

                @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.

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                1

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved