Include guards causing my code to break?

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.

Owen Alanzo Hogarth writes:

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

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/SDL2On Sat, 14 Nov 2015 15:05:19 +0800 Owen Alanzo Hogarth wrote:

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

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:

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:

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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://www.caveproductions.org

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 <martin.gerhardy at gmail.com> wrote:

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:

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 <@Owen_Alanzo_Hogarth> wrote:

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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://www.caveproductions.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org