IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C++ Discussion :

Convention d'appel. . . Msg d'erreur


Sujet :

C++

  1. #1
    Membre du Club Avatar de Array
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    210
    Détails du profil
    Informations personnelles :
    Âge : 32
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 210
    Points : 55
    Points
    55
    Par défaut Convention d'appel. . . Msg d'erreur
    Bonjour,

    Je suis débutant en C++, et je regardais hier un code auquel j'aimerais apporter des modifications. Le programme fait pour compiler sur GCC (MinGW), a quelques problèmes à compiler avec un compilateur plus... strict um.

    J'ai modifié le makefile pour qu'il puisse facilement compiler sous IntelCC.

    Mais, quand je compile, j'ai une erreur vrm très laxative :
    Citation Envoyé par icl
    [...] a calling convention may not be followed by a nested declarator [...]
    Voici l'extrait de code qui foire :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
     
    void EndDeferWindowPosAsync(HDWP hWinPosInfo)
    {
        if(usingNT)
        {
            // The kernel-mode part of the Windows USER API has a function called NtUserEndDeferWindowPosEx. 
            // This function takes two parameters - the HDWP (the same one used for *DeferWindowPos functions),
            // and a boolean parameter which dictates if the function should work asynchronously.
            // The 2nd parameter is only used internally from Task Manager, so it wouldn't hang while tiling windows.
            // EndDeferWindowPos in user32.dll is simply a wrapper around the NtUserEndDeferWindowPosEx syscall function,
            // similar to:
            // 
            // BOOL WINAPI EndDeferWindowPos(HDWP hWinPosInfo)
            // {
            //     return NtUserEndDeferWindowPosEx(hWinPosInfo, FALSE);
            // }
            // 
            // The following code will get the address of NtUserEndDeferWindowPosEx, and call it directly.
     
            HMODULE user32 = GetModuleHandle("user32.dll");
            unsigned char* func = (unsigned char*)GetProcAddress(user32, "EndDeferWindowPos");
            if(func && func[10]==0xE8)    // CALL IMM32 opcode
            {
                // --------------- ERREUR CI-DESSOUS
                typedef int WINAPI (*NtUserEndDeferWindowPosEx)(HDWP, BOOL);  // ERREUR -----------------------------
     
                // get address of NtUserEndDeferWindowPosEx, from within EndDeferWindowPos's code
                NtUserEndDeferWindowPosEx func2 = (NtUserEndDeferWindowPosEx) 
                    (func + 
                     15   +    // 10+5 (5 is size of the CALL instruction)
                     (func[11] <<  0 |     // CALL's argument is an offset relative to the address of the next instruction
                      func[12] <<  8 |
                      func[13] << 16 |
                      func[14] << 24));
     
                // call it
                func2(hWinPosInfo, TRUE);
            }
            else // something's wrong, do it normally
                EndDeferWindowPos(hWinPosInfo);
        }
        else
        {
            // the above can't apply to Win9x, try to create a simple thread to wrap around the potentially-blocking call
            DWORD tid;
            // this MIGHT be possible to write as CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)EndDeferWindowPos, ...) (that is, 
            // create the thread directly with the API), but the way compilers/linkers do DLL bindings could break this
            CloseHandle(CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)EndDeferWindowPosThreadProc, (LPVOID)hWinPosInfo, 0, &tid));
        }
    }
    Pourquoi le typedef en question provoque une erreur?
    Est-il possible de corriger ladite erreur simplement, ou est-ce une extension de GCC qui permet de compiler ledit code?

    Comment corriger l'erreur syntaxiquement parlant? (si bien sûr ça ne demande pas une réorganisation du code)

    Merci!

    Array

  2. #2
    Expert éminent
    Avatar de Melem
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2006
    Messages
    3 656
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 3 656
    Points : 8 389
    Points
    8 389
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    typedef int (WINAPI *NtUserEndDeferWindowPosEx)(HDWP, BOOL);
    Mais je préfère :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    typedef int WINAPI NTTRUCEX(HDWP, BOOL);
    typedef NTTRUCEX * LPNTTRUCEX;

  3. #3
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    Pour la version Win9x, le cast explicite en (LPTHREAD_START_ROUTINE) est hautement suspect...
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

Discussions similaires

  1. Excel VBA erreur 49 : Convention d'appel de DLL incorrecte
    Par Patrick.Pipet dans le forum Excel
    Réponses: 3
    Dernier message: 28/08/2014, 18h56
  2. [XL-2010] Erreur convention d'appel de .DLL incorrect sur import de classe
    Par comme de bien entendu dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 03/09/2011, 12h23
  3. Erreur d'execution '49': convention d'appel de DLL incorrecte
    Par papse dans le forum VB 6 et antérieur
    Réponses: 1
    Dernier message: 20/05/2009, 09h04
  4. Msg d'erreur: Erreur de traduction. Valeur hors des limites
    Par Zoilus dans le forum Bases de données
    Réponses: 5
    Dernier message: 20/12/2005, 16h15
  5. Fonctions Windows : convention d'appel C ou Pascal
    Par Alcatîz dans le forum x86 32-bits / 64-bits
    Réponses: 2
    Dernier message: 03/04/2003, 20h15

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo