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 :

prototype de fonction ?


Sujet :

C

  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2004
    Messages
    1 298
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2004
    Messages : 1 298
    Points : 886
    Points
    886
    Par défaut prototype de fonction ?
    Bonjour, j'ai tous plein de warning et d'erreurs que je n'arrive pas à résoudre. Voici une partie de mon fichier fonctions.h (qui contient les prototypes de mes fonctions utilisées)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    void LoadInitialInputs(char *,unsigned short *,IniCond *,double *,double *
    ,double *,double *,double *,double *,double *,double *,unsigned short *,char [],
    char []);
     
    void RandomInitialCondition(double,unsigned short,IniCond *,Mechanism *, Engine *,Vector *,Vector *,Vector *,double,N_Vector,double *,double *, double *,double *);
    voici une partie de mon fonction.c

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    void RandomInitialCondition(double t0,unsigned short Z,IniCond * ic,Mechanism * mec,Engine * e,Vector * esp_EGR,Vector * comp_EGR,Vector * atoms,double R,N_Vector y0,double * mz,double * pseafr,double * Tini,double * mtot)
    {
    blabla
    }
    et voici mon main.c jusqu'où il y a le bug :

    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
     
    int main(int argc,char * argv[])
    {
     
        unsigned int i,j,k;
     
    /*******************************
     *                             *
     * all initial data are stored *
     *                             *
     *******************************/
        IniCond * ic=CreateEmptyIniCond();
     
        /* Z : numbers of zones
           rpm : rotation per minute
           bore : length of the bore in cm
           rod : length of the rod in cm
           halfstroke : length of the half stroke in cm
           compratio : compression ratio
           turb : constant for the turbulence
           discret : discretisation of the crank angle for the output of the integration
           CA : initial crank angle in dV
           nbcycle : number of cycle compression-exhaust
        */    
        unsigned short Z,nbcycle;
        double rpm,bore,rod,halfstroke,compratio,turb,discret,CA;    
        char thermdata[50]; /* file containing thermodynamic data for each species */
        char syst[50]; /* file containing the system */
     
        /* Les paramètres de la ligne de commande ont une durée de vie égale à
           celle du programme, c'est garanti par la définition du langage C
           
           By default, the inputs file called "input.txt" but the user can use
           another file which will be read in argv[1]
        */
        char * inputfile= (argc==1) ? "input.txt" : argv[1];
     
        LoadInitialInputs(inputfile,&Z,ic,&rpm,&bore,&rod,&halfstroke,&compratio,&turb,&CA,&discret,&nbcycle,syst,thermdata);
     
        Mechanism * mec=LoadMechanism(syst,thermdata); /* mechanism is load */
        Temporary * temp=CreateTemporary(mec->nr,mec->ns,Z);    
     
        /*
          esp_EGR : vector which contains the number of the species of EGR
          comp_EGR : vector which contains the molar composition of each species
        */
        k=NumberSpaces(ic->egr->comp)+1; /* numbers species constituting EGR */
        Vector * esp_EGR=CreateVector(k,0.);
        Vector * comp_EGR=CreateVector(k,0.);
        CreateVectorEGR(ic->egr->comp,mec,esp_EGR,comp_EGR);    
     
        const unsigned short neq=Z*(mec->ns+1); /* numbers of equations */
     
        Vector * atoms=CreateVector(3,0.0);
        atoms->data[0]=7; atoms->data[1]=16;   
     
        Engine * e=CreateEngine(rpm,bore,rod,halfstroke,compratio);
     
        const double t0=RCONST((CA+180.0)/e->six_regime); /* initial time in s */
        const double dt=discret/e->six_regime; /* time step of discretisation in s */
        const realtype R=8.31451e7; /* gaz constante (erg/mol.K) */
        const realtype pa=1.0133e6; /* atmospheric pressure in dyne/cm2 */
     
     
        /************************************************
         *                                              *
         * pseudo-random initial condition of each zone *
         *                                              *
         ************************************************/
     
        /* Create serial vector of length neq for initial conditions */
        N_Vector y=NULL;
        y = N_VNew_Serial(neq);
        if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
     
        /* 
           y : index i(ns+1) to i(ns+1)+ns-1 : mass of each species of the ith
                                               zone i=0...N-1
           y : index (i+1)ns+i : temperature of the ith zone i=0...N-1
           ns : numbers of species of the mechanism
        */
     
        /* pseudo-random initial equivalence air-fuel ratio of each zone */
        double * pseafr=malloc(Z*sizeof(*pseafr)); assert(pseafr!=NULL);
     
        /* pseudo-random initial mass of each zone */
        double * mz=malloc(Z*sizeof(*mz)); assert(mz!=NULL);
     
        /* pseudo-random initial temperatures of each zone */
        double * Tini=malloc(Z*sizeof(*Tini)); assert(Tini!=NULL);
     
        double mtot; /* initial total mass of the mixture */
     
        RandomInitialCondition(t0,Z,ic,mec,e,esp_EGR,comp_EGR,atoms,R,y,mz,pseafr,Tini,&mtot);
     
    + la suite de mon main.c
    et voici ce que me dit le compilo :
    main.c: Dans la fonction « main »:
    main.c:168: attention : passage de l'argument n°2 de « RandomInitialCondition » transforme un entier en pointeur sans transtypage
    main.c:168: attention : passage de l'argument n°3 de « RandomInitialCondition » d'un type pointeur incompatible
    main.c:168: attention : passage de l'argument n°4 de « RandomInitialCondition » d'un type pointeur incompatible
    main.c:168: attention : passage de l'argument n°5 de « RandomInitialCondition » d'un type pointeur incompatible
    main.c:168: error: incompatible type for argument 7 of `RandomInitialCondition'
    main.c:168: attention : passage de l'argument n°8 de « RandomInitialCondition » d'un type pointeur incompatible
    main.c:168: error: incompatible type for argument 9 of `RandomInitialCondition'
    main.c:168: attention : passage de l'argument n°10 de « RandomInitialCondition » d'un type pointeur incompatible
    main.c:168: error: too many arguments to function `RandomInitialCondition'
    main.c:202: attention : passage de l'argument n°3 de « RandomInitialPressure » d'un type pointeur incompatible
    main.c:202: attention : passage de l'argument n°4 de « RandomInitialPressure » d'un type pointeur incompatible
    main.c:202: attention : passage de l'argument n°5 de « RandomInitialPressure » d'un type pointeur incompatible
    main.c:202: error: incompatible type for argument 6 of `RandomInitialPressure'
    main.c:202: error: incompatible type for argument 8 of `RandomInitialPressure'
    main.c:202: error: too few arguments to function `RandomInitialPressure'
    main.c:206: attention : passage de l'argument n°2 de « CoeffVolume » d'un type pointeur incompatible
    make: *** [main.o] Erreur 1
    Là j'avoue que je suis séché ! Pouvez-vous m'aider s'il vous plait ?

  2. #2
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2004
    Messages
    1 298
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2004
    Messages : 1 298
    Points : 886
    Points
    886
    Par défaut
    bonjour, bon j'ai trouvé le bug : en fait j'avais un autre fichier fonctions.h dans un autre répertoire (donc j'en avais deux qui avaient le même nom).

  3. #3
    Expert éminent sénior
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 67
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Points : 20 985
    Points
    20 985
    Par défaut
    Citation Envoyé par salseropom
    bonjour, bon j'ai trouvé le bug : en fait j'avais un autre fichier fonctions.h dans un autre répertoire (donc j'en avais deux qui avaient le même nom).
    Petite astuce pour savoir quel fichier inclus est pris en compte :
    ajouter (temporairement) une erreur "contrôlée" dans le .h :
    (Par exemple)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    #error "debug en cours..."
    Si elle se déclenche, le .h est bien inclus. Sinon, il n'est pas inclus et il faut en chercher la cause. Dans tous les cas, penser à retirer cette ligne quand on ne l'utilise plus !
    Pas de Wi-Fi à la maison : CPL

  4. #4
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2004
    Messages
    1 298
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2004
    Messages : 1 298
    Points : 886
    Points
    886
    Par défaut
    OK, merci.

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

Discussions similaires

  1. [POO] Prototypes de fonctions et IE
    Par T.NightGlow dans le forum Bibliothèques & Frameworks
    Réponses: 9
    Dernier message: 15/01/2008, 16h50
  2. definition prototypes de fonctions dans main
    Par fantomas261 dans le forum C
    Réponses: 4
    Dernier message: 19/10/2007, 11h18
  3. Question sur les prototypes de fonctions
    Par GnuVince dans le forum Langage
    Réponses: 2
    Dernier message: 23/11/2006, 23h37
  4. .net prototype de fonction
    Par stgi02 dans le forum MFC
    Réponses: 1
    Dernier message: 13/04/2006, 22h41

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