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 :

warning lors de la compilation "makes integer from pointer without a cast"


Sujet :

C

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    14
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Janvier 2009
    Messages : 14
    Points : 7
    Points
    7
    Par défaut warning lors de la compilation "makes integer from pointer without a cast"
    Bonjour à tous,

    Voilà après de nombreuses recherches je n'ai pas trouvé solution à mon pb : lorsque je compile mon prog, j'ai 2 warning qui doivent provenir du même pb.

    Le principe du code est le suivant : je fais appel à des fonctions provenant d'une dll créée avec LabVIEW. La dll contient 4 fonctions permettant de dialoguer avec un appareil :
    -ouverture du port COM
    -envoie d'un msg 'd'initialisation' et reception de d'un msg
    -envoie d'un msg concernant un volume d'une boucle et reception d'un msg
    -fermeture du port COM

    Voici mon code :
    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
     
    /******************************************************************************
      use_dll_auto2.c :
     
       Utilisation d'une dll créée sous LabVIEW
    ******************************************************************************/
     
    #include <windows.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
     
    /******************************************************************************
      main : point d'entrée du programme.
    ******************************************************************************/
    int main()
    {
        /* variables locales */
        long g_hCOM, pbitread, nIdIn, loopVol;
        long len=1;
        char BufferRead[256];
        unsigned char boolFctOPEN, boolFctWRITE, boolFctREAD, boolFctCLOSE;
     
    /*
    void __stdcall OpenCOM(long nIdIn, unsigned char *boolFctOPEN, long *g_hCOMOut);
    void __stdcall Initialise(long g_hCOMIn, long *pbitread, char BufferRead[], long len);
    void __stdcall Pfc_req_loop_vol(long g_hCOMIn, long *loopVol, unsigned char *boolFctREAD, unsigned char *boolFctWRITE, long *pbitread, char BufferRead[], long len);
    void __stdcall CloseCOM(long g_hCOMIn, unsigned char *boolFctCLOSE);
    */
     
        int nChoice = 1;
     
     
        HINSTANCE DLLHandle;
     
        typedef void(*Type_Pointeur_De_Fonction_OpenCOM)(long, unsigned char*, long*);
        Type_Pointeur_De_Fonction_OpenCOM Pointeur_Fonction_OpenCOM;
     
        typedef void(*Type_Pointeur_De_Fonction_Initialise)(long, long*, char, long);
        Type_Pointeur_De_Fonction_Initialise Pointeur_Fonction_Initialise;
     
        typedef void(*Type_Pointeur_De_Fonction_Pfc_req_loop_vol)(long, long*, unsigned char*, unsigned char*, long*, char, long);
        Type_Pointeur_De_Fonction_Pfc_req_loop_vol Pointeur_Fonction_Pfc_req_loop_vol;
     
        typedef void(*Type_Pointeur_De_Fonction_CloseCOM)(long, unsigned char*);
        Type_Pointeur_De_Fonction_CloseCOM Pointeur_Fonction_CloseCOM;
     
     
        DLLHandle = LoadLibrary("dll_auto2.dll");
        Pointeur_Fonction_OpenCOM = (Type_Pointeur_De_Fonction_OpenCOM)GetProcAddress(DLLHandle,"OpenCOM");
        Pointeur_Fonction_Initialise = (Type_Pointeur_De_Fonction_Initialise)GetProcAddress(DLLHandle,"Initialise");
        Pointeur_Fonction_Pfc_req_loop_vol = (Type_Pointeur_De_Fonction_Pfc_req_loop_vol)GetProcAddress(DLLHandle,"Pfc_req_loop_vol");
        Pointeur_Fonction_CloseCOM = (Type_Pointeur_De_Fonction_CloseCOM)GetProcAddress(DLLHandle,"CloseCOM");
     
     
        /* demande du numéro du port COM */
        printf("Entrez le numero du port COM : ");
        scanf("%ld", &nIdIn);
     
        /* tentative d'ouverture */
        printf("Ouverture et configuration du port COM%ld...\r\n", nIdIn);
        Pointeur_Fonction_OpenCOM(nIdIn, &boolFctOPEN, &g_hCOM);
        if(boolFctOPEN==1){
            printf("...OK\r\n");
        }
        else
     
        {
            return -1;
        }
     
        /* boucle tant que l'on ne quitte pas */
        while(nChoice != 3)
        {
            /*menu*/
            printf("\r\n");
            printf("1 : Init.\r\n");
            printf("2 : Loop vol.\r\n");
            printf("3 : Quitter.\r\n");
            printf("Choix : ");
            scanf("%d", &nChoice);
     
     
     
            if(nChoice == 1)
            {
                /*initialisation*/
                Pointeur_Fonction_Initialise(g_hCOM, &pbitread, BufferRead, len);
                printf("BufferRead : %s /r/n", BufferRead);
            }
            if(nChoice == 2)
            {
                /*lecture loop vol*/
                printf("\r\n");
                printf("Reception de donnees...\r\n");
                Pointeur_Fonction_Pfc_req_loop_vol(g_hCOM, &loopVol, &boolFctREAD, &boolFctWRITE, &pbitread, BufferRead, len);
                printf("%s, soit %ld bit lus\r\n", BufferRead, pbitread);
            }
        }
     
        /* fermeture du port COM et retour */
        Pointeur_Fonction_CloseCOM(g_hCOM, &boolFctCLOSE);
        printf("fermeture COM : %u \r\n", boolFctCLOSE);
        FreeLibrary(DLLHandle);  //on décharge la bibliothèque de la mémoire.
        return 0;
    }
    (J'ai remis en commentaire la définition des fonction de la dll)

    Voici les 2 warning que j'obtiens :

    In function `main'
    |89|warning: passing arg 3 of pointer to function makes integer from pointer without a cast|
    97|warning: passing arg 6 of pointer to function makes integer from pointer without a cast|
    ||=== Build finished: 0 errors, 2 warnings ===|
    Les erreurs sont sur ces lignes :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Pointeur_Fonction_Initialise(g_hCOM, &pbitread, BufferRead, len);
    Pointeur_Fonction_Pfc_req_loop_vol(g_hCOM, &loopVol, &boolFctREAD, &boolFctWRITE, &pbitread, BufferRead, len);
    Je travaille avec Code::block compilo GCC.

    Merci d'avance à tous ceux qui pourront m'aider sur ce pb.

    Fabrice

  2. #2
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    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 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Aurais-tu des problèmes en anglais?

    Type_Pointeur_Fonction_Initialise est déclaré avec un troisième paramètre de type char. Tu lui passes un paramètre implicitement converti en pointeur sur char.

    Je te laisse réfléchir pour l'autre erreur...

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    14
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Janvier 2009
    Messages : 14
    Points : 7
    Points
    7
    Par défaut
    Merci Médinoc, mon anglais va bien...,

    J'ai essayé un cast sur BufferRead, cela donne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Pointeur_Fonction_Initialise(g_hCOM, &pbitread, (char)BufferRead, len);
    Mais j'ai desormais le warning suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    |89|warning: cast from pointer to integer of different size
    Ai-je fais le cast correctement et si oui, comment régler ce pb de 'different size'.

    Merci d'avance pour ton aide.

    Fabrice

  4. #4
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    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 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Je pense que c'est la déclaration de la fonction qui est fausse, pas le paramètre.

Discussions similaires

  1. Réponses: 3
    Dernier message: 29/05/2014, 00h29
  2. assignment makes integer from pointer without a cast
    Par MaybeMaybe dans le forum Débuter
    Réponses: 6
    Dernier message: 05/01/2014, 20h50
  3. Réponses: 2
    Dernier message: 02/04/2010, 12h44
  4. Réponses: 25
    Dernier message: 04/10/2006, 00h33
  5. Warnings lors de la compilation
    Par polo54 dans le forum C
    Réponses: 5
    Dernier message: 07/02/2003, 09h12

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