[SDL] forward decleration problem

J Inacio jinacio3 at yahoo.com.br
Sat Jan 8 03:37:35 PST 2005


Hi

 Sory if I am misunderstending you, what do you want
meaning 'forwarding' is declare at a file and reuse
it?

 If is that, you can use extern.

-------------
some code:

main.c:

int t = 0;

int main(char argc, char * argv[]) {
 /* change value of t, for testing */
 t += 10;

 /*  print the t value (printit is in another file, 
  * but has access to t (becuse of extern)
 */
 printit();

 return 0;
}

test.c:
extern int t;

void printit() {
 printf("%d\n", t);
}
--------------
(you should see '10' on the output)

 --- Kostas Kostiadis <kos at climaxgroup.com> escreveu: 
> Hello all,
> 
> I have a header that has pointers to
> SDL_MouseMotionEvent and
> SDL_MouseButtonEvent,
> so at the top of the header I'm trying to forward
> declare these (then in the
> .cpp I include the
> appropriate header).
> 
> I have tried both
> 
> struct SDL_MouseMotionEvent; and
> typedef struct MouseMotionEvent;
> 
> but I keep getting these when using the GCC
> compiler:
> 
> In file included from
> Lib/Control/InputManager.cpp:11:
> Lib/Control/InputManager.h:18: error: conflicting
> declaration 'struct
> SDL_MouseMotionEvent'
> /usr/include/SDL/SDL_events.h:131: error:
> 'SDL_MouseMotionEvent' has a
> previous declaration as `typedef struct
> SDL_MouseMotionEvent
> SDL_MouseMotionEvent'
> Lib/Control/InputManager.h:19: error: conflicting
> declaration 'struct
> SDL_MouseButtonEvent'
> /usr/include/SDL/SDL_events.h:140: error:
> 'SDL_MouseButtonEvent' has a
> previous declaration as `typedef struct
> SDL_MouseButtonEvent
> SDL_MouseButtonEvent'
> 
> Any ideas?
> 
> cheers,
> K.
> 
> 
> 
> 
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>  

__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger 
http://br.download.yahoo.com/messenger/ 




More information about the SDL mailing list