#include "SDL/SDL.h" Vs. #include "SDL.h" |
JeZ-l-Lee
|
#include "SDL/SDL.h" Vs. #include "SDL.h" ???
Hi, I use SDL to design cross-platform video games. Which is the correct method to include SDL in my sources? #include "SDL/SDL.h" OR #include "SDL.h" On Linux it seems to be: #include "SDL/SDL.h" and on Windows it seems to be: #include "SDL.h" Just trying to have 1 code base for all platforms. My current (ugly) solution is the following: //------------------------------------------------------------------------------ #ifdef WIN32 #include "SDL.h" #include "SDL_image.h" #include "SDL_ttf.h" #include "SDL_opengl.h" #else #include "SDL/SDL.h" #include "SDL/SDL_image.h" #include "SDL/SDL_ttf.h" #include "SDL/SDL_opengl.h" #endif //------------------------------------------------------------------------------ Anyone have an ideas about this? Thanks... JeZ+Lee www.SilentHeroProductions.com _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
#include "SDL/SDL.h" Vs. #include "SDL.h" |
Alberto Luaces
Guest
|
Jesse Palser writes:
[...]
No. "sdl-config --cflags" outputs -I/usr/include/SDL (among other things), so the code should read also #include "SDL.h". -- Alberto _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
#include "SDL/SDL.h" Vs. #include "SDL.h" |
Jonny D
|
It is recommended to use "SDL.h" on every platform. Use compiler options or project options (depending on your IDE) to add the .../include/SDL path to your compiler search directories. For gcc, this is something like -I/usr/include/SDL. This is what I do, but it's even better to use `sdl-config --cflags` (backticks necessary) and use `sdl-config --libs` as a linker option.
Jonny D On Wed, Feb 17, 2010 at 7:58 AM, Jesse Palser wrote:
|
|||||||||||||
|
#include "SDL/SDL.h" Vs. #include "SDL.h" |
Bill Kendrick
Guest
|
On Wed, Feb 17, 2010 at 08:07:51AM -0500, Jonathan Dearborn wrote:
Backticks when calling from a shell, but in a Makefile you can (and I think should?) do it as, e.g.: SDL_CFLAGS=$(shell sdl-config --cflags) SDL_LIBS=$(shell sdl-config --libs) Just mentioning... -bill! _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
#include "SDL/SDL.h" Vs. #include "SDL.h" |
Alberto Luaces
Guest
|
Bill Kendrick writes:
In addition, in bash shell at least, you can use $() instead of the backticks: $(sdl-config --cflags) $(sdl-config --libs) -- Alberto _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
#include "SDL/SDL.h" Vs. #include "SDL.h& |
Eric Wing
Guest
|
On 8/4/10, Keybounce wrote:
#include <SDL/SDL.h> with work for your SDL Framework on OS X, but then you would need to do: #include <SDL_image/SDL_image.h> #include <SDL_mixer/SDL_mixer.h> etc. For frameworks, the "path" is actually the framework name. #include "SDL.h" is recommended for maximum code portability. Some distributions don't always put things in a directory called "SDL". Haven't verified in awhile, but once upon a time, FreeBSD put everything in a directory called SDL11 (even though it was 1.2). And obviously, OS X frameworks are going to have issues. So yes, you will need to add a long string of -I statements if you don't do the #include <SDL_image/SDL_image.h> stuff. I don't think you'll need the -F flags though since your frameworks are in standard locations and the linker will find these correctly/automatically. Some systems have special or different search paths for angle brackets than quotes. Generally speaking, quotes are better for things that aren't in these special compiler paths. -Eric _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
#include "SDL/SDL.h" Vs. #include "SDL.h& |
Donny Viszneki
Guest
|
I solved this problem two ways in my days of Mac OS X developing before Apple stabbed the FOSS community in the back :(
Solution A) Create your own sdl-config. It's really simple. Solution B) Write a little more code to include the necessary headers. Here's how I accomplished that: #ifdef APPLE # include <SDL/SDL.h> # include <OpenGL/GL.h> #else # include <SDL.h> # include <GL/gl.h> #endif Of course that solution is just from memory of many years ago, so it has a few rough edges. When you or someone else tries to build your package on another system, it quickly becomes apparent what the problem is and a fix is usually easy to implement, so the absence of a real standard portable one-liner isn't that critical :) On Wed, Aug 4, 2010 at 12:18 PM, Keybounce wrote:
-- http://codebad.com/ |
|||||||||||||
|
#include "SDL/SDL.h" Vs. #include "SDL.h& |
Gabriele Greco
Guest
|
I think that this solution.
There is also a third solution (C), that I think it's the better: Add the additional platform dependant include/link paths and flags to your build system files (makefiles, cmakelists.txt, xcode project, visual studio project....). It's always better to modify a project setting to make a project build on a particular platform/machine/enviroment that have to modify the sources with the risk of breaking the build on another platform or enviroment. Also, as Eric says, always use "" for non-system headers, not <>. -- Bye, Gabry |
|||||||||||||||
|
#include "SDL/SDL.h" Vs. #include "SDL.h& |
Vittorio Giovara
Guest
|
On Thu, Aug 5, 2010 at 12:45 AM, Donny Viszneki wrote:
as mentioned by others, #include "SDL.h" will work for most cases on most platforms. bye Vittorio |
|||||||||||||||
|
#include "SDL/SDL.h" Vs. #include "SDL.h& |
Vittorio G.
Guest
|
On Thu, Aug 5, 2010 at 12:45 AM, Donny Viszneki
wrote: I solved this problem two ways in my days of Mac OS X developing before Apple stabbed the FOSS community in the back :( when and how did this happen? Solution A) Create your own sdl-config. It's really simple. Solution B) Write a little more code to include the necessary headers. Here's how I accomplished that: #ifdef APPLE # include <SDL/SDL.h> # include <OpenGL/GL.h> #else # include <SDL.h> # include <GL/gl.h> #endif Of course that solution is just from memory of many years ago, so it has a few rough edges. When you or someone else tries to build your package on another system, it quickly becomes apparent what the problem is and a fix is usually easy to implement, so the absence of a real standard portable one-liner isn't that critical :) as mentioned by others, #include "SDL.h" will work for most cases on most platforms. bye Vittorio _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
#include "SDL/SDL.h" Vs. #include "SDL.h& |
Eric Wing
Guest
|
On 8/5/10, Gabriele Greco wrote:
I concur. And FYI, CMake already handles this case correctly and transparently if you use #include "SDL.h" #include "SDL_image.h" et al. I made sure of that ;) -Eric _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||||
|