Partage
  • Partager sur Facebook
  • Partager sur Twitter

error: expected init-declarator before "int"

non mais j'y crois pas!

    7 février 2008 à 11:36:56

    Bonjour à tout le monde!
    Dans un jeu que je suis en train de créer j'utilise un code source ( pour les collisions en SDL pour ceux qui connaissent ) trouvé sur internet et il n'arrive pas à compiler...

    A la ligne 44 je reçois:

    Citation : gcc

    SDL_collide.h:44: error: expected init-declarator before "int"
    SDL_collide.h:44: error: expected `,' or `;' before "int"



    Voici SDL_collide.h ( qui ne vient pas de moi je le rapelle )

    1. /*
    2.     SDL_collide:  A 2D collision detection library for use with SDL
    3.     Copyright (C) 2005 Amir Taaki
    4.     This library is free software; you can redistribute it and/or
    5.     modify it under the terms of the GNU Library General Public
    6.     License as published by the Free Software Foundation; either
    7.     version 2 of the License, or (at your option) any later version.
    8.     This library is distributed in the hope that it will be useful,
    9.     but WITHOUT ANY WARRANTY; without even the implied warranty of
    10.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    11.     Library General Public License for more details.
    12.     You should have received a copy of the GNU Library General Public
    13.     License along with this library; if not, write to the Free
    14.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    15.     Amir Taaki
    16.     genjix@gmail.com
    17.     Rob Loach
    18.     http://robloach.net
    19. */
    20. /* A simple library for collision detection using SDL */
    21. #ifndef _SDL_COLLIDE_h
    22. #define _SDL_COLLIDE_h
    23. /* Set up for C function definitions, even when using C++ */
    24. #ifdef __cplusplus
    25. extern "C" {
    26. #endif
    27. /*
    28.         SDL surface test if offset (u,v) is a transparent pixel
    29. */
    30. int SDL_CollideTransparentPixelTest(SDL_Surface *surface , int u , int v)
    31. /*
    32.         SDL pixel perfect collision test
    33. */
    34. int SDL_CollidePixel(SDL_Surface *as , int ax , int ay ,
    35.                        SDL_Surface *bs , int bx , int by)
    36. /*
    37.         SDL bounding box collision test
    38. */
    39. int SDL_CollideBoundingBox(SDL_Surface *sa , int ax , int ay ,
    40.                              SDL_Surface *sb , int bx , int by)
    41. /*
    42.         SDL bounding box collision tests (works on SDL_Rect's)
    43. */
    44. int SDL_CollideBoundingBox(SDL_Rect a , SDL_Rect b)
    45. /*
    46.         tests whether 2 circles intersect
    47.         circle1 : centre (x1,y1) with radius r1
    48.         circle2 : centre (x2,y2) with radius r2
    49.         (allow distance between circles of offset)
    50. */
    51. int SDL_CollideBoundingCircle(int x1 , int y1 , int r1 ,
    52.                                  int x2 , int y2 , int r2 , int offset)
    53. /*
    54.         a circle intersection detection algorithm that will use
    55.         the position of the centre of the surface as the centre of
    56.         the circle and approximate the radius using the width and height
    57.         of the surface (for example a rect of 4x6 would have r = 2.5).
    58. */
    59. int SDL_CollideBoundingCircle(SDL_Surface *a , int x1 , int y1 ,
    60.                                  SDL_Surface *b , int x2 , int y2 ,
    61.                                    int offset)
    62. /* Ends C function definitions when using C++ */
    63. #ifdef __cplusplus
    64. }
    65. #endif
    66. #endif /* _SDL_COLLIDE_h */


    J'ai bien sur essayé de mettre les ; à la fin des prototypes mais ça marche pas non plus...

    Quelqu'un utilisant ce code a-t-il déjà rencontré ce genre de problème? :-°

    Merci de me renseigner
    • Partager sur Facebook
    • Partager sur Twitter
      7 février 2008 à 12:44:54

      Il faut bien sur les point-virgule à la fin du prototype (sans ça, ils ne sont tout simplement pas considérés comme prototypes).

      Je mise sur le fait que dans le *.c ou tu inclus cet en-tête, tu l'inclus en premier, avant les en-tête de la SDL non ?
      Si c'est le cas, fait l'inverse et dis nous si ça change quelque chose ;)
      • Partager sur Facebook
      • Partager sur Twitter
        7 février 2008 à 14:00:00

        Non:

        voici main.cpp ;)
        1. #include <string>//pour les chaînes de caractères
        2. #include <cstdlib>//pour les fonctions C
        3. #include <list>//STL
        4. #include <iostream>
        5. #include <math.h>
        6. #include <SDL/SDL.h>
        7. #include "projectile.h"
        8. #include "unite.h"
        9. #include "vecteur.h"
        10. #include "constantes.h"
        11. #include "SDL_collide.h"


        nb:le reste du programme est écrit en c++ d'où les en-têtes
        • Partager sur Facebook
        • Partager sur Twitter
          7 février 2008 à 14:13:32

          hé bien.. sur ma machine ce code compile sans problème (avec les point-virgule bien sur).


          Une question que je me pose : tu as deux fonctions polymorphes dans le bloc extern "C" {}, c'est légale ça ?
          • Partager sur Facebook
          • Partager sur Twitter
            7 février 2008 à 14:41:39

            je sais pas (ce code vient pas de moi) mais j'ai réussi à regler cette erreur en enlevant le bloc c et en mettant l'extention cpp à SDL_collide.c...

            Maintenant, il me vient toute une série d'erreur du genre

            Citation : gcc

            main.cpp:46: undefined reference to `Unite::getJoueur() const'

            et il y en a pour tous mes fichiers cpp. !

            Encore un problème d'include?
            • Partager sur Facebook
            • Partager sur Twitter

            error: expected init-declarator before "int"

            × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
            × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
            • Editeur
            • Markdown