FORUM Syndrome-OC - Jacky-PC


  Programmation


  Langage haut niveau(C, Pascal...)


  [C/C++][NOOB INSIDE] Quel compilateur pour ce code ?[RESOLU]

 




guy68 et 37 utilisateurs inconnus

 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[C/C++][NOOB INSIDE] Quel compilateur pour ce code ?[RESOLU]

n°5076
Blue Sn4ke
Zelda Fan
Posté le 01-03-2005 à 21:49:17  profilanswer
 

[MODE NOOB]
 
Bonjour  :hello:  
 
http://www.cppfrance.com/code.aspx?ID=25449
 
Voila j'ai trouvé ça, j'aimerais bien l'essayer mais heu problème : j'en fais quoi de la source ? J'ai essayé d'y mettre dans dev c++ mais j'ai un parse error :/
 
Quel compileur me faut-il ?  
 
Merci
[/MODE NOOB]


Message édité par Blue Sn4ke le 03-03-2005 à 18:34:22
mood
Google
Posté le 01-03-2005 à 21:49:17  profilanswer
 

n°5077
Deather2
OpenBSD: the way to go!
Posté le 01-03-2005 à 21:57:56  profilanswer
 

Elle est à quelle ligne la parse error?
En tout cas quel code immonde [:fred durst]

n°5078
Blue Sn4ke
Zelda Fan
Posté le 01-03-2005 à 22:25:20  profilanswer
 

Voila ce que Dev-C++ renvoie :
 
32 c:\windows\bureau\lcd.cpp parse error before `edx'
41 c:\windows\bureau\lcd.cpp parse error before `edx'
 
Sinon pour le code immonde si tu veux l'optimiser un peu pour moi n'hésite pas [:dslam]


Message édité par Blue Sn4ke le 01-03-2005 à 22:25:37
n°5079
Dr Lous
I see old password
Posté le 01-03-2005 à 23:46:16  profilanswer
 

mon dieu [:grut]
(remarque je sais pas si c'est mieux pour moi XDD)
 
je vais chercher mon code pour le lcd :)


---------------
Oseras-tu m'affronter ?
n°5080
Dr Lous
I see old password
Posté le 01-03-2005 à 23:47:00  profilanswer
 

Code :
  1. /* compiler avec gcc -O2 pour les macros inb et outb */
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. #include <asm/io.h>
  5. #define lpt_port 0x378  /* Changer l'adresse du port ici */
  6. #define STATUS lpt_port+1
  7. #define CONTROL lpt_port+2
  8. /* Une série de définitions pour simplifier la programmation */
  9. #define SET_E outb(inb(CONTROL) & 254,CONTROL)  /* E=1 (Strobe) */
  10. #define RAZ_E outb(inb(CONTROL) | 1,CONTROL)  /* E=0 (Strobe) */
  11. #define SET_RS outb(4,CONTROL) /* RS=1, la donnée est un caractère */
  12. #define RAZ_RS outb(0,CONTROL) /* RS=0, la donnée est une instruction */
  13. void Init_LCD (void);
  14. void Efface_LCD (void);
  15. void Ecrire_LCD (char *Chaine, char Position);
  16. int coco;
  17. /*
  18. Adresse du curseur (en hexadécimal):
  19.  
  20. digit  : 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
  21.  
  22. ligne 1: 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F 90 91 92 93
  23. ligne 2: C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3
  24. ligne 3: 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7
  25. ligne 4: D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7
  26. */
  27. int main(void)
  28. {
  29. char *Phrase1="Taper",
  30.  *Phrase2="Votre",
  31.  *Phrase3="Message Sur",
  32.  *Phrase4="La console";
  33. if(ioperm(lpt_port,3,1))
  34. {
  35.     perror("ioperm" );
  36.     exit(1);
  37. }
  38.  Init_LCD();
  39.  //clrscr();
  40.  printf("*************************************************\n" );
  41.  printf("*    Programme de test d'un ecran LCD 4 * 20    *\n" );
  42.  printf("*************************************************\n\n\n" );
  43.  Ecrire_LCD(Phrase1,0x80);
  44.  Ecrire_LCD(Phrase2,0xC0);
  45.  Ecrire_LCD(Phrase3,0x94);
  46.  Ecrire_LCD(Phrase4,0xD4);
  47.  //printf("Taper le message puis Enter.\n" );
  48.  
  49.  while (1)
  50.  {
  51.   coco = getchar();
  52.   if (coco == 47) //si caractere egale a    "/" effacement ecran...
  53.   {
  54.    printf("\n\n----EFFACEMENT ECRAN!!!----\n\n" );
  55.    RAZ_RS;
  56.    outb(0x01,lpt_port); // mise des valeur sur le port
  57.    SET_E;
  58.    usleep(2000);
  59.    RAZ_E;
  60.    usleep(2000);
  61.    SET_RS;
  62.   }
  63.   else
  64.   {
  65.    if (coco == 10)
  66.    {
  67.      //printf("Bouh\n" );
  68.    }
  69.    else
  70.    {
  71.     if (coco == 176){coco = 223;}
  72.     if (coco == 40){coco = 255;}
  73.     printf("-'%d'\n", coco);
  74.      outb(coco,lpt_port); // mise des valeur sur le port
  75.     SET_E;
  76.     usleep(10);
  77.     RAZ_E;
  78.     usleep(10);
  79.    }
  80.   }
  81.   if (coco == 81)
  82.   {
  83.    Efface_LCD();
  84.    Ecrire_LCD("MERCI D'AVOIR",0xC0);
  85.    Ecrire_LCD("UTILISE Dr-LCD",0x94);
  86.    exit();
  87.   }
  88.  }
  89.  printf("%d",0x30);
  90.  return 0;
  91. }
  92. void Init_LCD (void)
  93. {
  94. char Init[5],i;
  95. Init[0] =  0x30;
  96. Init[1] =  0x38;
  97. Init[2] =  0x0F;
  98. Init[3] =  0x01;
  99. Init[4] =  0x06;
  100. outb(inb(CONTROL) & 0xDF,CONTROL); /* On place le port parallèle en sortie */
  101. RAZ_RS;
  102. for(i=0;i<=4;i++)
  103. {
  104.  outb(Init[i],lpt_port); /* On place la donnée sur le bus */
  105.  SET_E;
  106.  usleep(20000); /* Délais de 20 ms */
  107.  RAZ_E;
  108.  usleep(20000);
  109. }
  110. SET_RS;
  111. }
  112. void Efface_LCD (void)
  113. {
  114. RAZ_RS;
  115. outb(0x01,lpt_port); /* On place l'instruction d'effacement sur le bus */
  116. SET_E;
  117. usleep(20000);
  118. RAZ_E;
  119. usleep(2000);
  120. SET_RS;
  121. }
  122. void Ecrire_LCD (char Chaine[20], char Position)
  123. {
  124. int i,Taille;
  125. Taille=strlen(Chaine);
  126. RAZ_RS;
  127. outb(Position,lpt_port); /* Adresse d'écriture */
  128. SET_E;
  129. usleep(1);
  130. RAZ_E;
  131. usleep(1);
  132. SET_RS;
  133. for(i=0;i<Taille;i++)
  134. {
  135.  outb(Chaine[i],lpt_port); /* On place la donnée sur le bus */
  136.  SET_E;
  137.  usleep(1);
  138.  RAZ_E;
  139.  usleep(1);
  140. }
  141. }


---------------
Oseras-tu m'affronter ?
n°5082
Blue Sn4ke
Zelda Fan
Posté le 02-03-2005 à 13:49:02  profilanswer
 

Slt, ca c'est le code pour linux non ?
 
Sous linux faut faire comment pour le compiler (mandrake 10.1) ?
 
Si je fais en console : gcc -02 nomfichier.cpp ca renvoie :
 

Code :
  1. gcc: unrecognized option `-02'
  2. gcc: installation problem, cannot exec `cc1plus': No such file or directory


Que faire ?
 
edit : ta variable coco elle sert à quoi ?
 
 
merci


Message édité par Blue Sn4ke le 02-03-2005 à 13:52:22
n°5083
Deather2
OpenBSD: the way to go!
Posté le 02-03-2005 à 13:56:22  profilanswer
 

Salut,
c'est -O pas -0 ;)
donc:
gcc -O3 -o nom_executable lefichier.c
 
si c'est un cpp, remplacer gcc par g++ ;)

n°5084
Blue Sn4ke
Zelda Fan
Posté le 02-03-2005 à 13:57:37  profilanswer
 

ah oki j'essaie de suite je te tiens au courant :)

n°5085
Blue Sn4ke
Zelda Fan
Posté le 02-03-2005 à 14:01:22  profilanswer
 

Voila ce que ça renvoie
 

[damien@damien Desktop]$ gcc -O2 lcd lcd.c
gcc: lcd: No such file or directory
lcd.c:3: error: syntax error at '#' token
lcd.c:3: error: syntax error before '<' token
lcd.c:4: error: syntax error at '#' token
lcd.c:5: error: syntax error at '#' token
lcd.c:7: error: syntax error at '#' token
lcd.c:8: error: syntax error at '#' token
lcd.c:9: error: syntax error at '#' token
lcd.c:12: error: syntax error at '#' token
lcd.c:13: error: syntax error at '#' token
lcd.c:14: error: syntax error at '#' token
lcd.c:15: error: syntax error at '#' token
lcd.c:32: error: syntax error before "int"
lcd.c:39: error: syntax error before "if"
lcd.c:42: error: syntax error before numeric constant
lcd.c:42: warning: conflicting types for built-in function 'exit'
lcd.c:42: warning: data definition has no type or storage class
lcd.c:43: error: syntax error before '}' token
lcd.c:44: warning: data definition has no type or storage class
lcd.c:46: error: syntax error before string constant
lcd.c:46: warning: conflicting types for built-in function 'printf'
lcd.c:46: warning: data definition has no type or storage class
lcd.c:47: error: syntax error before string constant
lcd.c:47: error: conflicting types for 'printf'
lcd.c:46: error: previous declaration of 'printf' was here
lcd.c:47: error: conflicting types for 'printf'
lcd.c:46: error: previous declaration of 'printf' was here
lcd.c:47: warning: data definition has no type or storage class
lcd.c:48: error: syntax error before string constant
lcd.c:48: warning: data definition has no type or storage class
lcd.c:49: error: syntax error before numeric constant
lcd.c:49: warning: data definition has no type or storage class
lcd.c:50: error: syntax error before numeric constant
lcd.c:50: warning: data definition has no type or storage class
lcd.c:51: error: syntax error before numeric constant
lcd.c:51: warning: data definition has no type or storage class
lcd.c:52: error: syntax error before numeric constant
lcd.c:52: warning: data definition has no type or storage class
lcd.c:56: error: syntax error before "while"
lcd.c:62: warning: data definition has no type or storage class
lcd.c:63: error: syntax error before numeric constant
lcd.c:63: warning: data definition has no type or storage class
lcd.c:64: warning: data definition has no type or storage class
lcd.c:65: error: syntax error before numeric constant
lcd.c:65: warning: data definition has no type or storage class
lcd.c:66: warning: data definition has no type or storage class
lcd.c:67: error: syntax error before numeric constant
lcd.c:67: warning: data definition has no type or storage class
lcd.c:68: warning: data definition has no type or storage class
lcd.c:69: error: syntax error before '}' token
lcd.c:80: error: syntax error before string constant
lcd.c:80: warning: data definition has no type or storage class
lcd.c:81: warning: parameter names (without types) in function declaration
lcd.c:81: warning: data definition has no type or storage class
lcd.c:82: warning: data definition has no type or storage class
lcd.c:83: error: syntax error before numeric constant
lcd.c:83: warning: data definition has no type or storage class
lcd.c:84: warning: data definition has no type or storage class
lcd.c:85: error: syntax error before numeric constant
lcd.c:85: warning: data definition has no type or storage class
lcd.c:86: error: syntax error before '}' token
lcd.c:91: error: syntax error before string constant
lcd.c:91: warning: data definition has no type or storage class
lcd.c:92: error: syntax error before string constant
lcd.c:92: warning: data definition has no type or storage class
lcd.c:93: warning: data definition has no type or storage class
lcd.c:94: error: syntax error before '}' token
lcd.c:96: error: syntax error before '}' token
lcd.c:97: error: syntax error before string constant
lcd.c:97: warning: data definition has no type or storage class
lcd.c:98: error: syntax error before "return"
lcd.c:102: error: syntax error before "void"
lcd.c:106: error: invalid initializer
lcd.c:106: warning: data definition has no type or storage class
lcd.c:107: error: conflicting types for 'Init'
lcd.c:106: error: previous definition of 'Init' was here
lcd.c:107: error: invalid initializer
lcd.c:107: warning: data definition has no type or storage class
lcd.c:108: error: conflicting types for 'Init'
lcd.c:107: error: previous definition of 'Init' was here
lcd.c:108: error: conflicting types for 'Init'
lcd.c:107: error: previous definition of 'Init' was here
lcd.c:108: error: invalid initializer
lcd.c:108: warning: data definition has no type or storage class
lcd.c:109: error: conflicting types for 'Init'
lcd.c:108: error: previous definition of 'Init' was here
lcd.c:109: error: conflicting types for 'Init'
lcd.c:107: error: previous definition of 'Init' was here
lcd.c:109: error: invalid initializer
lcd.c:109: warning: data definition has no type or storage class
lcd.c:110: error: conflicting types for 'Init'
lcd.c:109: error: previous definition of 'Init' was here
lcd.c:110: error: conflicting types for 'Init'
lcd.c:107: error: previous definition of 'Init' was here
lcd.c:110: error: invalid initializer
lcd.c:110: warning: data definition has no type or storage class
lcd.c:113: error: syntax error before '(' token
lcd.c:114: warning: data definition has no type or storage class
lcd.c:115: error: syntax error before "for"
lcd.c:118: warning: data definition has no type or storage class
lcd.c:119: error: syntax error before numeric constant
lcd.c:119: warning: data definition has no type or storage class
lcd.c:120: warning: data definition has no type or storage class
lcd.c:121: error: syntax error before numeric constant
lcd.c:121: warning: data definition has no type or storage class
lcd.c:122: error: syntax error before '}' token
lcd.c:123: warning: data definition has no type or storage class
lcd.c:124: error: syntax error before '}' token
lcd.c:126: error: syntax error before "void"
lcd.c:129: error: syntax error before numeric constant
lcd.c:129: warning: data definition has no type or storage class
lcd.c:130: warning: data definition has no type or storage class
lcd.c:131: error: syntax error before numeric constant
lcd.c:131: warning: data definition has no type or storage class
lcd.c:132: warning: data definition has no type or storage class
lcd.c:133: error: syntax error before numeric constant
lcd.c:133: warning: data definition has no type or storage class
lcd.c:134: warning: data definition has no type or storage class
lcd.c:135: error: syntax error before '}' token
lcd.c:137: error: syntax error before "void"
lcd.c:140: error: `Chaine' undeclared here (not in a function)
lcd.c:140: warning: initialization makes pointer from integer without a cast
lcd.c:140: error: initializer element is not constant
lcd.c:140: warning: data definition has no type or storage class
lcd.c:141: warning: data definition has no type or storage class
lcd.c:142: warning: parameter names (without types) in function declaration
lcd.c:142: warning: data definition has no type or storage class
lcd.c:143: warning: data definition has no type or storage class
lcd.c:144: error: syntax error before numeric constant
lcd.c:144: warning: data definition has no type or storage class
lcd.c:145: warning: data definition has no type or storage class
lcd.c:146: error: syntax error before numeric constant
lcd.c:146: warning: data definition has no type or storage class
lcd.c:147: warning: data definition has no type or storage class
lcd.c:148: error: syntax error before "for"
lcd.c:151: warning: data definition has no type or storage class
lcd.c:152: error: syntax error before numeric constant
lcd.c:152: warning: data definition has no type or storage class
lcd.c:153: warning: data definition has no type or storage class
lcd.c:154: error: syntax error before numeric constant
lcd.c:154: warning: data definition has no type or storage class
lcd.c:155: error: syntax error before '}' token
lcd.c:156:8: warning: no newline at end of file


 
Faut que je mette une extension au fichier exécutable ? Laquelle ?


Message édité par Blue Sn4ke le 02-03-2005 à 14:02:09
n°5086
Deather2
OpenBSD: the way to go!
Posté le 02-03-2005 à 14:02:39  profilanswer
 

gcc -O2 -o lcd lcd.c
 
t'as zappé le -o ;)

n°5087
Blue Sn4ke
Zelda Fan
Posté le 02-03-2005 à 14:06:23  profilanswer
 

ca met toujours la même chose :/

n°5088
Deather2
OpenBSD: the way to go!
Posté le 02-03-2005 à 14:14:42  profilanswer
 

Je crois voir le problème,
Edite le post de Dr lous, et copie le code entre les balises [ cpp ].
 
Faut pas le copier directement depuis le post.
Ensuite il faut modifier à la ligne 91 exit(); en exit(0);, sûrement un ptit oubli :D
Et ça compile bien :)

n°5089
Blue Sn4ke
Zelda Fan
Posté le 02-03-2005 à 14:21:01  profilanswer
 

Avec gcc ca renvoie :
 
gcc: installation problem, cannot exec `cc1plus': No such file or directory
 
Avec g++ :
 
bash: g++: command not found
 
Merci
 
edit : t'as réussi à le compiler toi ?


Message édité par Blue Sn4ke le 02-03-2005 à 14:21:35
n°5090
Deather2
OpenBSD: the way to go!
Posté le 02-03-2005 à 14:23:26  profilanswer
 

Moi oui ça compile sans problème avec gcc...
J'comprend pas pourquoi y'a besoin de g++ de toute manière, c'est du C pas du C++ :/
Essaye d'installer le compilateur C++ avec urpmi, sinon j'peux t'envoyer l'executable ;)

n°5091
Dr Lous
I see old password
Posté le 02-03-2005 à 16:11:13  profilanswer
 

Deather2 a écrit :

Je crois voir le problème,
Edite le post de Dr lous, et copie le code entre les balises [ cpp ].
 
Faut pas le copier directement depuis le post.
Ensuite il faut modifier à la ligne 91 exit(); en exit(0);, sûrement un ptit oubli :D
Et ça compile bien :)


 
 
code a l'arrache en juin 2004 ;)
donc oui ya pas mal a modifier ;)


---------------
Oseras-tu m'affronter ?
n°5092
Blue Sn4ke
Zelda Fan
Posté le 02-03-2005 à 17:05:18  profilanswer
 

Deather2 a écrit :

Moi oui ça compile sans problème avec gcc...
J'comprend pas pourquoi y'a besoin de g++ de toute manière, c'est du C pas du C++ :/
Essaye d'installer le compilateur C++ avec urpmi, sinon j'peux t'envoyer l'executable ;)


t'as quelle distrib ? moi j'ai une mdk 10.1, ca vient ptetre de la...
 
 
 
:'(


Message édité par Blue Sn4ke le 02-03-2005 à 17:05:32
n°5093
Deather2
OpenBSD: the way to go!
Posté le 02-03-2005 à 17:09:11  profilanswer
 

Normalement toutes les distribs on GCC et G++ d'installée :D

n°5094
Deadog
Dain Bramaged
Posté le 02-03-2005 à 20:12:49  profilanswer
 

Deather2 a écrit :

Normalement toutes les distribs on GCC et G++ d'installée :D


 
 
 :non:  
 
par defaut, y'en a pratiquement aucune qui l'ont
 
 
et le code provenant de cppfrance ne marchera pas sur un windows récent puisque ce code fait des accès aux ports direct, ce qui est interdit depuis 2k


Message édité par Deadog le 02-03-2005 à 20:14:04
n°5095
Deather2
OpenBSD: the way to go!
Posté le 02-03-2005 à 20:40:06  profilanswer
 

oki ;)

n°5097
Blue Sn4ke
Zelda Fan
Posté le 02-03-2005 à 21:25:14  profilanswer
 

Oki, Deather m'a bien aidé sur msn (;)) mais on n'arrive toujours pas a compiler ce #!^§?;[ de prog... :/
 
Deather le compile très bien, mes chez moi pas moyen, ca pourrait venir du fait que g++ c'est pas installé chez moi ?
 
Merci à tous

n°5119
Blue Sn4ke
Zelda Fan
Posté le 03-03-2005 à 17:04:08  profilanswer
 

Personne ne sait pourquoi quand j'essaie de compiler mon prg ca renvoie  
 
gcc: installation problem, cannot exec `cc1plus': No such file or directory  
 
?
merci

n°5120
Blue Sn4ke
Zelda Fan
Posté le 03-03-2005 à 18:35:39  profilanswer
 

Ayai, problème résolu !
 
Il "suffisait" de faire chmod 755 /usr/include/c++ en root !!!
 
Merci à tous !

n°5121
Dr Lous
I see old password
Posté le 03-03-2005 à 18:39:42  profilanswer
 

il faut que cc1plus soit accecible a gcc (ou g++) ou que son repertoire soit dans $PATH ;)


---------------
Oseras-tu m'affronter ?
n°5122
Dr Lous
I see old password
Posté le 03-03-2005 à 18:40:01  profilanswer
 

arf grilled


---------------
Oseras-tu m'affronter ?
mood
Google
Posté le 03-03-2005 à 18:40:01  profilanswer
 


Aller à :
Ajouter une réponse

  FORUM Syndrome-OC - Jacky-PC


  Programmation


  Langage haut niveau(C, Pascal...)


  [C/C++][NOOB INSIDE] Quel compilateur pour ce code ?[RESOLU]

 

Hit Parade