FORUM Tom's Hardware » Programmation » C / C++ / Java » Erreur de compilation
 

Erreur de compilation

Overclocking & Tuning : fifi2191 et 79 utilisateurs inconnus
Ajouter une réponse



 Mot :   Pseudo :  
 
Bas de page
Auteur
 Sujet : Erreur de compilation
 
Plus d'informations

J ai un ti soucis au niveau de la compilation de mon programme :
 
voici la partie qui fait erreur :  :fou:  
 

Code :
  1. while(1) {
  2.         int buf_size = 0;
  3.         int nb_read = 0;
  4.         float* volume;
  5.         unsigned char from_board[6];
  6.         unsigned char from_board2[4];
  7.         unsigned char to_board[32];
  8.         float z_be;
  9.         float z_le;
  10.         unsigned char* pz_be;
  11.         unsigned char* pz_le;
  12.         unsigned char* answer_ptr = from_board;
  13.         float z_noise;
  14.         pz_be = (unsigned char *)&z_be;
  15.         pz_le = (unsigned char *)&z_le;
  16.         while ((nb_read = read(answer_ptr, 6 - buf_size)) > 0){
  17.             buf_size += nb_read;
  18.             answer_ptr += nb_read;
  19.             printf("POUET %d\n", nb_read);
  20.             if(buf_size >= 6)
  21.                 break;
  22.         }
  23.         if(buf_size != 6)
  24.             continue;


 
Apres compilation les erreus sont les suivantes : :fou:  
 
c:\documents and settings\nicolas\desktop\simulator_profile_tvarminne\simu_finlande.c(98) : warning C4013: 'lis_parametres_flotteur' undefined; assuming extern returning int
c:\documents and settings\nicolas\desktop\simulator_profile_tvarminne\simu_finlande.c(135) : warning C4047: 'function' : 'int ' differs in levels of indirection from 'unsigned char *'
c:\documents and settings\nicolas\desktop\simulator_profile_tvarminne\simu_finlande.c(135) : warning C4024: 'read' : different types for formal and actual parameter 1
c:\documents and settings\nicolas\desktop\simulator_profile_tvarminne\simu_finlande.c(135) : warning C4022: 'read' : pointer mismatch for actual parameter 2
c:\documents and settings\nicolas\desktop\simulator_profile_tvarminne\simu_finlande.c(135) : error C2198: 'read' : too few actual parameters
Error executing cl.exe.
 
Je trouve pourtant que ma syntaxe n a pas d erreur... Il me semble hein ^^
Le problemes etant que je n est trouves aucune infornation a se sujet (bien sure cette partie en commentaire tous fonctionne),
Si quelqun peut m eclairer merci beaucoup! :hello:  
 

C is a sharp tool
Plus d'informations

a écrit :

J ai un ti soucis au niveau de la compilation de mon programme :
 
voici la partie qui fait erreur :


Le code étant incomplet, impossible de le tester.


---------------
Des infos sur la programmation et le langage C:
http://bien-programmer.blogspot.com/
http://mapage.noos.fr/emdel/

 

Plus d'informations

voici le code complet :
 

Code :
  1. #include "automatique.h"
  2. #include "simu_finlande.h"
  3. #define DT (2.0)
  4. #define PATH "C:\\simulator_profile\\profil_swarm_conductivity.txt"
  5. double param_phys[10];
  6. double etat_systeme[3];
  7. double Temperature, Conductivity, Salinity;
  8. double RHO;
  9. double Table_profile[78][4];
  10. FILE* profil_fd;
  11.  
  12.       #ifdef WIN32 //allow Gettimeofday fonction to works.
  13.  
  14.       #include <time.h>
  15.       #include <sys/timeb.h> 
  16.  
  17.       int gettimeofday (struct timeval *tp, void *tz)
  18.  
  19.       {
  20.  
  21.           struct _timeb timebuffer;
  22.  
  23.           _ftime (&timebuffer);
  24.  
  25.           tp->tv_sec = timebuffer.time;
  26.  
  27.           tp->tv_usec = timebuffer.millitm * 1000;
  28.  
  29.           return 0;
  30.  
  31.       }
  32.  
  33.       #endif
  34. /*int open_port(char port[10]) {
  35.     int fd;
  36.     struct termios options;
  37.     //fd = open(port, O_RDWR | O_NOCTTY);
  38.     fd = open(port, O_RDWR | O_NOCTTY | O_NDELAY);
  39.     if (fd == -1) {
  40.         fprintf(stderr, "open_port: Unable to open %s - %s\n", port, strerror(errno));
  41.     }
  42.     bzero(&options, sizeof(options));
  43.     cfsetispeed(&options, B9600);
  44. //no parity bit
  45.     options.c_cflag &= ~PARENB;
  46.     options.c_cflag &= ~CSTOPB;
  47.     options.c_cflag &= ~CSIZE;
  48.     options.c_cflag |= CS8;
  49. //not owner of the port
  50.     options.c_cflag     |= (CLOCAL | CREAD);
  51. //raw input characters are passed through exactely as they arrived
  52.     options.c_lflag     &= ~(ICANON | ECHO | ECHOE | ISIG);
  53. //raw output     
  54.     options.c_oflag     &= ~OPOST;
  55.      
  56.     options.c_cc[VMIN]  = 0;
  57.     options.c_cc[VTIME] = 20; // 2 seconds  
  58.     tcflush(fd, TCIOFLUSH);
  59.     tcsetattr(fd, TCSANOW, &options);
  60.     return fd;
  61. }*/
  62. float noisify()
  63. {
  64.     float noise;
  65.     noise = (int)(11.0*rand()/(RAND_MAX + 1.0))-5.0;
  66.     if (noise == 0)
  67.         noise = 1;
  68. //    noise = 3.0e-2 * fabs(noise)/noise;
  69.     noise = 0.0;
  70.     return noise;
  71. }
  72. int main(int argc, char *argv[]) {
  73.    // int serial_fd;
  74.     FILE* log_fd;
  75.     struct timeval tv,tv1;
  76.    
  77.     //initialisation de la seed pour le générateur de nombres aléatoires */
  78.    
  79.     srand((unsigned)time(NULL));
  80.     log_fd = fopen("log", "w+" );
  81.     //serial_fd = open_port("/dev/ttyS0" );
  82.     printf("Port ouvert\n" );
  83.     lis_parametres_flotteur("config_flotteur" );
  84.     printf("Config lue\n" );
  85.    
  86.    
  87.     /*reading of the profile which simulate the environment*/
  88.     profil_fd=fopen(PATH, "r" );
  89.     if (profil_fd == NULL) {
  90.         printf("no profile in the folder\n" );
  91.     }
  92.     read_profile();
  93.    
  94.     /*initialisation*/
  95.     etat_systeme[0]=1.5;    /*simulate the position of the sensor in the bottom of the float*/
  96.     etat_systeme[1]=0;
  97.     //initialize temperature, conductivity and salinity
  98.     read_sensors(etat_systeme[0]);
  99.     RHO = density_computing(etat_systeme[0], Temperature, Salinity); 
  100.     printf("init %g %g %g %g %g\n\n", etat_systeme[0], Temperature, Conductivity, Salinity, RHO);
  101.     gettimeofday(&tv, NULL);
  102.     gettimeofday(&tv1, NULL);
  103.     while(1) {
  104.         int buf_size = 0;
  105.         int nb_read = 0;
  106.         float* volume;
  107.         unsigned char from_board[6];
  108.         unsigned char from_board2[4];
  109.         unsigned char to_board[32];
  110.         float z_be;
  111.         float z_le;
  112.         unsigned char* pz_be;
  113.         unsigned char* pz_le;
  114.         unsigned char* answer_ptr = from_board;
  115.         float z_noise;
  116.         pz_be = (unsigned char *)&z_be;
  117.         pz_le = (unsigned char *)&z_le;
  118.      /*   while ((nb_read = read(answer_ptr, 6 - buf_size)) > 0){
  119.             buf_size += nb_read;
  120.             answer_ptr += nb_read;
  121.             printf("POUET %d\n", nb_read);
  122.             if(buf_size >= 6)
  123.                 break;
  124.         }
  125.         if(buf_size != 6)
  126.             continue;
  127.         */ 
  128.     printf("from board %x%x%x%x%x%x\n", from_board[0], from_board[1], from_board[2], from_board[3],
  129.     from_board[4], from_board[5]);
  130.         from_board2[0] = from_board[1];
  131.         from_board2[1] = from_board[2];
  132.         from_board2[2] = from_board[3];
  133.         from_board2[3] = from_board[4];
  134.     volume=(float *)from_board2;
  135.         etat_systeme[2]=(double)*volume;
  136.         printf("VOLUME: %g\n", etat_systeme[2]);
  137.         merson(etat_systeme[2], 0.0, DT, Temperature);
  138.         z_noise = noisify();
  139.         z_le = (float)((etat_systeme[0] + z_noise)/(10.0));
  140.         // conversion en big endian
  141.         //for(buf_size=3; buf_size>=0; buf_size--)
  142.         //    *(pz_be+buf_size)=*(pz_le+3-buf_size);
  143.     /*update value of temperature et conductivity*/
  144.     read_sensors(etat_systeme[0]);
  145.        
  146.     //sprintf(to_board,"$AQCTD,12.000,0%2.3f,10.000*ff\n",fabs(z_le+1));
  147.     sprintf(to_board,"$AQCTD,%2.3f,0%2.3f,%2.3f*ff\n",Temperature, fabs(z_le+1), Conductivity);
  148.        // write(serial_fd, to_board, 32);
  149.         gettimeofday(&tv, NULL);
  150.     printf("delay between 2 interrupts : %g\n", (tv.tv_sec - tv1.tv_sec +
  151.                 (tv.tv_usec-tv1.tv_usec)*1.0e-6));
  152.     printf("%s", to_board);
  153.         printf("%g %g %g %g %g %g %g %g\n\n", etat_systeme[0], z_le, etat_systeme[1], etat_systeme[2], Temperature,
  154.     Conductivity, Salinity, RHO);
  155.         fprintf(log_fd, "%g %g %g %g %d.%d %g %g %g %g %x%x%x%x%x%x\n", etat_systeme[0],
  156.                 etat_systeme[1], etat_systeme[2], z_noise, tv.tv_sec, tv.tv_usec,
  157.         Temperature, Conductivity, Salinity, RHO,
  158.         from_board[0], from_board[1], from_board[2], from_board[3],from_board[4], from_board[5]);
  159.         fflush(log_fd);
  160.         tv1.tv_sec=tv.tv_sec;
  161.         tv1.tv_usec=tv.tv_usec;
  162.     }
  163.     exit(0);
  164. }
  165. int lis_parametres_flotteur(char* config_file){
  166.     int i = 0;
  167.     double valeur_lue;
  168.     FILE* config_fd;
  169.     config_fd = fopen(config_file, "r" );
  170.     if (config_fd == NULL){
  171.         exit(1);
  172.     }
  173.     while(fscanf(config_fd, "%lf", &valeur_lue) == 1) {
  174.         param_phys[i]=valeur_lue;
  175.        if(i>10){
  176.            exit(1);
  177.        }
  178.        i++;
  179.     }
  180.     return EXIT_SUCCESS;
  181. }
  182. void read_profile(void)
  183. {
  184.     int i;
  185.     double value;
  186.     for (i = 0; i<78; i++)
  187.     {
  188.         if (fscanf(profil_fd, "%lf\n", &value) == 1){
  189.             Table_profile[i][0] = value;
  190.         }
  191.         if (fscanf(profil_fd, "%lf\n", &value) == 1){
  192.             Table_profile[i][1] = value;
  193.         }
  194.         if (fscanf(profil_fd, "%lf\n", &value) == 1){
  195.             Table_profile[i][2] = value;
  196.         }
  197.         if (fscanf(profil_fd, "%lf\n", &value) == 1){
  198.             Table_profile[i][3] = value;
  199.         }
  200.     }
  201. }
  202. void read_sensors(double depth)
  203. {
  204.     int i = 0;
  205.     //double delta;
  206.     while(Table_profile[i][0] < depth){
  207.         i++;
  208.     }
  209.     Temperature = Table_profile[i][1];
  210.     Conductivity = Table_profile[i][2];
  211.     Salinity = Table_profile[i][3];
  212. }


 
j ai pas encore trouver pourquoi sa plante ...


Message édité par araschbab le 27-04-2006 à 14:18:35
zeb
Profil : Modérateur libre
Plus d'informations

Révise le chapitre sur le prototypage.
En effet, tu utilises la fonction lis_parametres_flotteur ligne 98, mais elle n'est définie que ligne 191

Plus d'informations

heu oui je l ai declarer apres les defines autant pour moi mais l erreur de vient pas de la.
 
int lis_parametres_flotteur(char* config_file);

Profil : Pointeur
Plus d'informations

et lire les messages d'erreur ca te viendrais pas a l'esprit ?


---------------
Da Bidz Triad©®™: Bidz Interceptor
.:: Smileyz version 4.2 [050625]::. -- Code source disponible sous licence GPL.
[u
Plus d'informations

Bien au contraire les messages d erreur je les regarde! mais je sais pas ce que sa veut dire surtout celui la.
 
 
c:\documents and settings\nicolas\desktop\simulator_profile_tvarminne\simu_finlande.c(135) : error C2198: 'read' : too few actual parameters
Error executing cl.exe.

C is a sharp tool
Plus d'informations

a écrit :

c:\documents and settings\nicolas\desktop\simulator_profile_tvarminne\simu_finlande.c(135) : error C2198: 'read' : too few actual parameters


"Pas assez de paramètres formels."
 
Tu appelles une fonction avec un nombre insuffisant de paramètres.


---------------
Des infos sur la programmation et le langage C:
http://bien-programmer.blogspot.com/
http://mapage.noos.fr/emdel/

 

Plus d'informations

Oki. C est le prototype de la fonction qui n est pas bon?
je ne vois pas comment y palier.

C is a sharp tool
Plus d'informations

a écrit :

Oki. C est le prototype de la fonction qui n est pas bon?
je ne vois pas comment y palier.


Il faut qu'il y ait cohérence entre l'appel et le prototype. C'est ton code...
 
Si il s'agit de l'appel de read() qui est une fonction système, le prototype est bon (si tu as bien inclus le header qui va bien). C'est à toi de modifier l'appel pour qu'il soit cohérent.
Si il s'agit de cet appel (il est commenté)

Code :
  1. read(answer_ptr, 6 - buf_size)


il y a effectivement un problème...

Code :
  1. ssize_t read(int fd, void *buf, size_t count);


Message édité par Emmanuel D elahaye le 28-04-2006 à 09:35:49

---------------
Des infos sur la programmation et le langage C:
http://bien-programmer.blogspot.com/
http://mapage.noos.fr/emdel/

 

Plus d'informations

Citation :

ssize_t read(int fd, void *buf, size_t count);


 
oui le prototype est bon.pourtant je n arrive pas a voir l erreur, mon code me semble bon. l appel est bienune fonctionsysteme auquel j ai inclus les header qu il convient.

Plus d'informations

en utilisant fread() j enleve la plus part des warnings mais toujours pas l erreur.

C is a sharp tool
Plus d'informations

a écrit :

Citation :

ssize_t read(int fd, void *buf, size_t count);


 
oui le prototype est bon.pourtant je n arrive pas a voir l erreur, mon code me semble bon. l appel est bienune fonctionsysteme auquel j ai inclus les header qu il convient.


Tu ne vois donc pas que la fonction read() attend 3 paramètres et que tu lui en passes que 2 ?


Message édité par Emmanuel D elahaye le 28-04-2006 à 10:36:17

---------------
Des infos sur la programmation et le langage C:
http://bien-programmer.blogspot.com/
http://mapage.noos.fr/emdel/

 

C is a sharp tool
Plus d'informations

a écrit :

en utilisant fread() j enleve la plus part des warnings mais toujours pas l erreur.


Il ne faut pas utiliser les fonctions au hasard...
 
C'est soit
open() read() close() (fonctions systèmes)
soit
fopen() fread() fclose() (fonctions standards du C)
Mais pas un mélange entre les deux. Encore une fois il faut être cohérent. Tu as appris le C comment ?


Message édité par Emmanuel D elahaye le 28-04-2006 à 10:38:48

---------------
Des infos sur la programmation et le langage C:
http://bien-programmer.blogspot.com/
http://mapage.noos.fr/emdel/

 

Plus d'informations

Quelques notions a L IUT electronique! Mais la cela me bloque parcequ il me reste plus que cette erreur. J ai pas un gros niveau en C++je le sais, je suis capable de voir ce que fait tel ou tel fonction,ecrire du code mais sa vas pas plus loin....

zeb
Profil : Modérateur libre
Plus d'informations

M'enfin, Il suffit de savoir compter jusqu'à 3.

Plus d'informations

si on pouvait m expliquer?

zeb
Profil : Modérateur libre
Plus d'informations