The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
include guards causing my code to break?
Owen Alanzo Hogarth
Guest

I am having a bit of trouble with some `#include` guards.


I am using SDL and have my code defined like this:


    #include "SDL.h"
    #if __MACOSX__
    #define GL_GLEXT_PROTOTYPES
    #include <SDL2/SDL_opengl.h>
    #elif __ANDROID__
    #include "SDL_opengles2.h"
    #elif __LINUX__
    #include "SDL_opengl.h"
    #endif


this is already a bit off because for example on macos x there is no SDL.h it's located at <SDL/SDL.h>
for linux SDL.h work and for windows I don't even know just yet.


with the above code I get 


    implicit declaration of some of the opengl functions error


if I move the `#include SDL_openg.h` outside of the include guard things work just fine on linux but then there are the errors on mac.
include guards causing my code to break?
Eirik Byrkjeflot Anonsen
Guest

Owen Alanzo Hogarth writes:

Quote:
I am having a bit of trouble with some `#include` guards.

I am using SDL and have my code defined like this:

#include "SDL.h"
#if __MACOSX__
#define GL_GLEXT_PROTOTYPES
#include <SDL2/SDL_opengl.h>
#elif __ANDROID__
#include "SDL_opengles2.h"
#elif __LINUX__
#include "SDL_opengl.h"
#endif

this is already a bit off because for example on macos x there is no SDL.h
it's located at <SDL/SDL.h>
for linux SDL.h work and for windows I don't even know just yet.

with the above code I get

implicit declaration of some of the opengl functions error

if I move the `#include SDL_openg.h` outside of the include guard things
work just fine on linux but then there are the errors on mac.

Maybe it would work better if you use "#if defined __MACOSX__" instead
of "#if __MACOSX__" (etc.)?

Chances are those defines are defined to empty values, and empty values
do not evaluate to true for #if.

eirik
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
include guards causing my code to break?
Driedfruit
Guest

Just my 2 cents, ans slightly off-topic, but...

I think it might be a good idea not to use #ifdef's for include paths
at all, and offset that to compiler flags (or appropriate settings for
you IDE/whatever). I.e

#include <SDL.h>
gcc -I/usr/local/include/SDL2

On Sat, 14 Nov 2015 15:05:19 +0800
Owen Alanzo Hogarth wrote:

Quote:
I am having a bit of trouble with some `#include` guards.

I am using SDL and have my code defined like this:

#include "SDL.h"
#if __MACOSX__
#define GL_GLEXT_PROTOTYPES
#include <SDL2/SDL_opengl.h>
#elif __ANDROID__
#include "SDL_opengles2.h"
#elif __LINUX__
#include "SDL_opengl.h"
#endif

this is already a bit off because for example on macos x there is no
SDL.h it's located at <SDL/SDL.h>
for linux SDL.h work and for windows I don't even know just yet.

with the above code I get

implicit declaration of some of the opengl functions error

if I move the `#include SDL_openg.h` outside of the include guard
things work just fine on linux but then there are the errors on mac.



--
driedfruit
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
include guards causing my code to break?
M. Gerhardy
Guest

Also it looks looks you are mixing gles with gl - and if you are using any fixed function pipeline stuff that is no longer available in gles... this won't work, too.


I suppose you get those implicit decl errors on android?


On Sat, Nov 14, 2015 at 7:00 PM, Driedfruit wrote:
Quote:
Just my 2 cents, ans slightly off-topic, but...

I think it might be a good idea not to use #ifdef's for include paths
at all, and offset that to compiler flags (or appropriate settings for
you IDE/whatever). I.e

#include <SDL.h>
gcc -I/usr/local/include/SDL2

On Sat, 14 Nov 2015 15:05:19 +0800
Owen Alanzo Hogarth wrote:

Quote:
I am having a bit of trouble with some `#include` guards.

I am using SDL and have my code defined like this:

     #include "SDL.h"
     #if __MACOSX__
     #define GL_GLEXT_PROTOTYPES
     #include <SDL2/SDL_opengl.h>
     #elif __ANDROID__
     #include "SDL_opengles2.h"
     #elif __LINUX__
     #include "SDL_opengl.h"
     #endif

this is already a bit off because for example on macos x there is no
SDL.h it's located at <SDL/SDL.h>
for linux SDL.h work and for windows I don't even know just yet.

with the above code I get

     implicit declaration of some of the opengl functions error

if I move the `#include SDL_openg.h` outside of the include guard
things work just fine on linux but then there are the errors on mac.





--
driedfruit
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





--
http://www.caveproductions.org
include guards causing my code to break?
Owen Alanzo Hogarth
Guest

Driedfruit that's actually a pretty good idea, I didn't think about that. I'll try that since I am using CMAKE.

M. Gerhardy I am only using opengles 2.0 and opengl 330 core that's the base line for this project. I don't do any fix function OpenGL.


On Sun, Nov 15, 2015 at 5:00 AM, M. Gerhardy wrote:
Quote:
Also it looks looks you are mixing gles with gl - and if you are using any fixed function pipeline stuff that is no longer available in gles... this won't work, too.


I suppose you get those implicit decl errors on android?


On Sat, Nov 14, 2015 at 7:00 PM, Driedfruit wrote:
Quote:
Just my 2 cents, ans slightly off-topic, but...

I think it might be a good idea not to use #ifdef's for include paths
at all, and offset that to compiler flags (or appropriate settings for
you IDE/whatever). I.e

#include <SDL.h>
gcc -I/usr/local/include/SDL2

On Sat, 14 Nov 2015 15:05:19 +0800
Owen Alanzo Hogarth wrote:

Quote:
I am having a bit of trouble with some `#include` guards.

I am using SDL and have my code defined like this:

     #include "SDL.h"
     #if __MACOSX__
     #define GL_GLEXT_PROTOTYPES
     #include <SDL2/SDL_opengl.h>
     #elif __ANDROID__
     #include "SDL_opengles2.h"
     #elif __LINUX__
     #include "SDL_opengl.h"
     #endif

this is already a bit off because for example on macos x there is no
SDL.h it's located at <SDL/SDL.h>
for linux SDL.h work and for windows I don't even know just yet.

with the above code I get

     implicit declaration of some of the opengl functions error

if I move the `#include SDL_openg.h` outside of the include guard
things work just fine on linux but then there are the errors on mac.





--
driedfruit
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







--
http://www.caveproductions.org





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org