SDL /C /C++ erreur

Résolu/Fermé
freesta Messages postés 591 Date d'inscription mercredi 26 novembre 2008 Statut Membre Dernière intervention 12 avril 2012 - 30 juin 2011 à 10:18
freesta Messages postés 591 Date d'inscription mercredi 26 novembre 2008 Statut Membre Dernière intervention 12 avril 2012 - 1 juil. 2011 à 09:45
Bonjour,

j'ai un soucis avec un point h de la SDL,
lors de la compilation de mon programme, j'ai l'erreur:
C:\Program Files\CodeBlocks\SDL-1.2.14\include\SDL\SDL_image.h
|38|error: expected identifier or '(' before '{' token|
merci de votre aide , je cherche mais je ne trouve pas!

voicis le code du fichier:

/*SDL_image: An example image loading library for use with SDL
Copyright (C) 1999-2004 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA Sam Lantinga slouken@libsdl.org*//*
$Id: SDL_image.h,v 1.17 2004/01/04 17:33:01 slouken Exp $ *//*
A simple library to load images of various formats as SDL surfaces */

#ifndef _SDL_IMAGE_H
#define _SDL_IMAGE_H

#include "SDL.h"
#include "SDL_version.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */

#ifdef __cplusplus
extern "C" {
#endif
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL*/

#define SDL_IMAGE_MAJOR_VERSION 1
#define SDL_IMAGE_MINOR_VERSION 2
#define SDL_IMAGE_PATCHLEVEL 4
/* This macro can be used to fill a version structure with the compile-time *
version of the SDL_image library.
*/
#define SDL_IMAGE_VERSION(X)
{/*ligne38*/
(X)->major = SDL_IMAGE_MAJOR_VERSION;
(X)->minor = SDL_IMAGE_MINOR_VERSION;
(X)->patch = SDL_IMAGE_PATCHLEVEL;}

/* This function gets the version of the dynamically linked SDL_image library.
it should NOT be used to fill a version structure, instead you should
use the SDL_IMAGE_VERSION() macro. */
extern DECLSPEC const SDL_version * SDLCALL IMG_Linked_Version(void);
/* Load an image from an SDL data source.
The 'type' may be one of: "BMP", "GIF", "PNG", etc.
If the image format supports a transparent pixel, SDL will set the
colorkey for the surface. You can enable RLE acceleration on the
surface afterwards by calling: SDL_SetColorKey(image, SDL_RLEACCEL,
image->format->colorkey); */
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type);
/* Convenience functions */
extern DECLSPEC SDL_Surface * SDLCALL IMG_Load(const char *file);
extern DECLSPEC SDL_Surface * SDLCALL IMG_Load_RW(SDL_RWops *src, int freesrc);
/* Invert the alpha of a surface for use with OpenGL
This function is now a no-op, and only provided for backwards compatibility.*/
extern DECLSPEC int SDLCALL IMG_InvertAlpha(int on);
/* Functions to detect a file type, given a seekable source */
extern DECLSPEC int SDLCALL IMG_isBMP(SDL_RWops *src);
extern DECLSPEC int SDLCALL IMG_isPNM(SDL_RWops *src);
extern DECLSPEC int SDLCALL IMG_isXPM(SDL_RWops *src);
extern DECLSPEC int SDLCALL IMG_isXCF(SDL_RWops *src);
extern DECLSPEC int SDLCALL IMG_isPCX(SDL_RWops *src);
extern DECLSPEC int SDLCALL IMG_isGIF(SDL_RWops *src);
extern DECLSPEC int SDLCALL IMG_isJPG(SDL_RWops *src);
extern DECLSPEC int SDLCALL IMG_isTIF(SDL_RWops *src);
extern DECLSPEC int SDLCALL IMG_isPNG(SDL_RWops *src);
extern DECLSPEC int SDLCALL IMG_isLBM(SDL_RWops *src);
/* Individual loading functions */
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadBMP_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNM_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXPM_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXCF_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPCX_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadGIF_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadJPG_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTIF_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNG_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTGA_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadLBM_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_ReadXPMFromArray(char **xpm);
/* We'll use SDL for reporting errors */
#define IMG_SetError SDL_SetError
#define IMG_GetError SDL_GetError
/* Ends C function definitions when using C++
*/#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* _SDL_IMAGE_H */


2 réponses

Char Snipeur Messages postés 9696 Date d'inscription vendredi 23 avril 2004 Statut Contributeur Dernière intervention 3 octobre 2023 1 297
30 juin 2011 à 10:40
la macro est mal définie. essai :
#define SDL_IMAGE_VERSION(X)\
{\
(X)->major = SDL_IMAGE_MAJOR_VERSION;\
(X)->minor = SDL_IMAGE_MINOR_VERSION;\
(X)->patch = SDL_IMAGE_PATCHLEVEL;} 
0
freesta Messages postés 591 Date d'inscription mercredi 26 novembre 2008 Statut Membre Dernière intervention 12 avril 2012 26
30 juin 2011 à 11:00
merci,
mais maintenant j'ai encore plus d'erreur:

|34|more undefined references to 'IMG_Load' follow|

et les warning lol
||=== Build finished: 6 errors, 700 warnings ===|

need help!

sources:
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>

#include "constantes.h"
#include "jeu.h"

void jouer(SDL_Surface* ecran)
{
SDL_Surface *mario[4] = {NULL}; // 4 surfaces pour chacune des directions de mario
SDL_Surface *mur = NULL, *caisse = NULL, *caisseOK = NULL, *objectif = NULL, *marioActuel = NULL;
SDL_Rect position, positionJoueur;
SDL_Event event;

int continuer = 1, objectifsRestants = 0, i = 0, j = 0;
int carte[NB_BLOCS_LARGEUR][NB_BLOCS_HAUTEUR] = {0};

// Chargement des sprites (décors, personnage...)
mur = IMG_Load("mur.jpg");//ligne34
caisse = IMG_Load("caisse.jpg");
caisseOK = IMG_Load("caisse_ok.jpg");
objectif = IMG_Load("objectif.png");
0
Char Snipeur Messages postés 9696 Date d'inscription vendredi 23 avril 2004 Statut Contributeur Dernière intervention 3 octobre 2023 1 297
30 juin 2011 à 11:07
Là, je c'est une erreur d'édition des liens. Il doit manqué une bibliothèque, (SDL, à tout hasard).
0
freesta Messages postés 591 Date d'inscription mercredi 26 novembre 2008 Statut Membre Dernière intervention 12 avril 2012 26
30 juin 2011 à 11:15
justement je pensait que c'était la bibliotèque SDL_image.h mais apprarament non, ra je vais j'ammais y arrivé!
sa fait 2 jour que je regarde comment marche le SDL, je suis entrain d'aprendre, pour ensuite apprendre l'open gl , et ensuite le niveau au dessus.

je vois pas quel autre bibliotèque sa pourais être! faut que je recherche sur le net!
0
freesta Messages postés 591 Date d'inscription mercredi 26 novembre 2008 Statut Membre Dernière intervention 12 avril 2012 26
30 juin 2011 à 11:34
oui c'est bien dans SDL_image.h que IMG_Load et définis

extern DECLSPEC SDL_Surface * SDLCALL IMG_Load(const char *file);

je vois pas la! help stp
0
Char Snipeur Messages postés 9696 Date d'inscription vendredi 23 avril 2004 Statut Contributeur Dernière intervention 3 octobre 2023 1 297
30 juin 2011 à 14:30
le .h c'est pour la compilation, mais ensuite, il faut lié avec la bibliothèque. un truc dont le nom doit être du genre libSDL.a. Selon le compilateur et l'OS ainsi que l'EDI, il y a plusieurs manière de l'ajouter.
0
freesta Messages postés 591 Date d'inscription mercredi 26 novembre 2008 Statut Membre Dernière intervention 12 avril 2012 26
1 juil. 2011 à 09:45
oui j'ai fait sa aussi , mais le problem venais d'une erreur dans le projet j'en ai créer un nouveau et j'ai lié tout mes ficher sa marche! merci de ton aide!
0