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

MFC Discussion :

[MFC] Comment Utiliser des fonction declarées dans des fichiers (*.c)


Sujet :

MFC

  1. #1
    Débutant
    Profil pro
    Développeur informatique
    Inscrit en
    Avril 2006
    Messages
    245
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Avril 2006
    Messages : 245
    Points : 81
    Points
    81
    Par défaut [MFC] Comment Utiliser des fonction declarées dans des fichiers (*.c)
    En fait j'ait des fonctions declarées dans des fichiers (*.c) et pas de fichiers (*.h) car c'est l'architecture utilisée par l'entreprise.

    je dois creer un simulateur avec VC++ et utiliser
    ces fonctions. j'ai inclu le fichier .c correspondant, mais à la compilation ca me donne ca comme message d'erreur :

    error C2065: 'cpaCommOpenConnectionInet' : undeclared identifier



    comment je peux regler ca?

  2. #2
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

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

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Points : 17 323
    Points
    17 323
    Par défaut
    en consultat la faq

  3. #3
    Membre éprouvé
    Avatar de Gabrielly
    Inscrit en
    Juin 2004
    Messages
    722
    Détails du profil
    Informations forums :
    Inscription : Juin 2004
    Messages : 722
    Points : 1 128
    Points
    1 128
    Par défaut
    En fait j'ait des fonctions declarées dans des fichiers (*.c) et pas de fichiers (*.h) car c'est l'architecture utilisée par l'entreprise.
    Pas très bonne façon de procéder.

    Montre un peu à quoi ressemble ton *.c

  4. #4
    Débutant
    Profil pro
    Développeur informatique
    Inscrit en
    Avril 2006
    Messages
    245
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Avril 2006
    Messages : 245
    Points : 81
    Points
    81
    Par défaut
    Oui comme ca :

    #include "../src/cpa_client_comm.c"
    extern "C" int cpaCommOpenConnectionInet(void);

    mais j'ai toujours un probleme de linkage, le suivant :

    Linking...
    FreeSimuDlg.obj : error LNK2001: unresolved external symbol _cpaCommOpenConnectionInet
    Debug/FreeSimu.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    Comment je peux le regler ca?

  5. #5
    Débutant
    Profil pro
    Développeur informatique
    Inscrit en
    Avril 2006
    Messages
    245
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Avril 2006
    Messages : 245
    Points : 81
    Points
    81
    Par défaut
    Mon *.c est le suivant :
    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
     
    #include <stdlib.h>
    #include <stdio.h>
    #include <sys/types.h>
    #include <signal.h>
    #include <fcntl.h>
    #include <errno.h>
    #include <winsock2.h>
    #include <string.h>
    #include <io.h>
    #include <time.h>
    #include <memory.h>
    #include <windows.h>
    #include <windowsx.h>
     
    #pragma comment(lib, "ws2_32.lib")
     
    static char rBuf[2048];
     int sockFd;
     
     
     
    int cpaCommOpenConnectionInet(void /*int fd*/)
    { 
     static const char __func__[] = "cpaCommOpenConnectionInet";
        /* connect to socket */
        struct sockaddr_in  addr;
        //struct sigaction action;
        struct hostent* server;
        sockFd = socket( AF_INET, SOCK_STREAM, 0 ); 
        memset( &addr, 0, sizeof(addr) );
        server = gethostbyname("10.160.41.89");
        addr.sin_family = AF_INET;
     memcpy((char *) server->h_addr, (char *) &addr.sin_addr.s_addr, server->h_length);
        addr.sin_port = htons(1096);
        if ( connect( sockFd, (struct sockaddr*) &addr, sizeof( addr ) ) == 0 )
        {
            printf("Success to connect with TAPI Server \n" );
            //cpaSetSocketBlock(sockFd, 1 );
           // action.sa_sigaction = cpaAsyncSignal;
            //action.sa_flags = /*SA_SIGINFO*/SIGILL;
            //sigemptyset(&action.sa_mask);
      if (signal(sockFd/*fd*/,(void*)SIGILL) < 0) {  //if(sigaction(SIGNAL_IO, &action, NULL) < 0) {
                perror("sigaction");
                exit(1);
            }
            cpaTriggerAsyncRead(sockFd, sizeof(cpaMessageHeaderT), CPA_MESSAGE_HEADER);
        }
        else
        {
            printf("Fail to connect with TAPI Server, %s \n", strerror(errno) );
            cpaCloseSocketFd( sockFd );
            sockFd = -1;
            exit(-1);
        }  
        return sockFd; 
    }

  6. #6
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

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

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Points : 17 323
    Points
    17 323
    Par défaut
    c'est sur qu'en procedant comme ça ne risque pas de fonctionner
    le post de la faq est pourtant clair !
    http://c.developpez.com/faq/vc/?page=IDE#MixCAndCPlus

  7. #7
    Débutant
    Profil pro
    Développeur informatique
    Inscrit en
    Avril 2006
    Messages
    245
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Avril 2006
    Messages : 245
    Points : 81
    Points
    81
    Par défaut
    C Bon.

    Le probleme est reglé
    Merci

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 07/05/2015, 14h39
  2. Réponses: 0
    Dernier message: 14/04/2015, 10h34
  3. [Débutant] Utiliser des fonctions VB dans des clauses SQL
    Par noftal dans le forum VB.NET
    Réponses: 10
    Dernier message: 02/11/2013, 17h41
  4. [JAXB] Comment utiliser JAXB pour le mapping des classes définies dans mon XSD ?
    Par yassirjanati dans le forum Format d'échange (XML, JSON...)
    Réponses: 1
    Dernier message: 13/10/2011, 13h54
  5. Utiliser des fonctions contenues dans un fichier .bas
    Par usbeck dans le forum Visual C++
    Réponses: 4
    Dernier message: 11/08/2006, 12h03

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