• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
jeff8j

c++ include define DIR

6 posts in this topic

I am trying to set a directory to a define like #define DIR "/dir"

and use that to include a bunch of files like #include DIR+"header.h"

this is not working its giving me #include expects "FILENAME" or <FILENAME>

is there some way of making this work or does the preprocessor not work like this?
0

Share this post


Link to post
Share on other sites

Hmm that sucks theres so much it can do you would think it could do that somehow.

 

I have 37 header files I want to include that are in a versioned directory ie library-0.4.1/

I could rename the folder to just library but I was wanting to keep multiple versions to change them easily.

When 0.4.2 comes out I could simply change dir defined path to library-0.4.2 and if I dont like it or it doesnt pass the tests I could revert easily

0

Share this post


Link to post
Share on other sites

Hmm that sucks theres so much it can do you would think it could do that somehow.

 

I have 37 header files I want to include that are in a versioned directory ie library-0.4.1/

I could rename the folder to just library but I was wanting to keep multiple versions to change them easily.

When 0.4.2 comes out I could simply change dir defined path to library-0.4.2 and if I dont like it or it doesnt pass the tests I could revert easily

Add a path to that library in the "Additional Include Directories" (for Visual Studio), or whatever is the same thing in your IDE.  Then you can include files from that directory like this:

 

#include <subfolder/file.h>  // where "subfolder" is a folder inside whatever path you told the compiler about

 

This will give you exactly what you want.

Edited by 0r0d
1

Share this post


Link to post
Share on other sites

You could do this:

 

#define HEADER(path) "/dir/" ## path
 
#include HEADER("my path/file.h")

 

But really, it's better to just specify "/dir/" manually so as to not confuse others reading your code (including yourself in the future).

 

If "/dir/" is long, then make sure you specify your compiler's include paths properly. In gcc and MinGW, this is: "gcc -I <include path>" (That -I is a uppercase 'i'). You can specify multiple include paths to search.

1

Share this post


Link to post
Share on other sites

As mentioned above, there's a whole bunch of methods that are all better than abusing the preprocessor for this.

 

a) If stuff is versioned, why not use a version control system instead of folder names?

b) Failing that, the -I option exists for exactly that kind of thing (ie. it belongs in your project settings or Makefile, not the actual source code)

c) Use a symlink that points to whatever version you want to use (yes, Windows finally has them too)

1

Share this post


Link to post
Share on other sites

@0r0d that would do it I can set the paths in gcc but not quite the solution I was hoping for

 

@Servant of the Lord Thats exactly what I was looking for although its giving me an error im still messing with it to figure it out.

 

@Trienco

a. The local versions differ from the actual version granted I could setup my own version control but I dont want other parts of the program to revert just this single part I could setup 2 one for the library and one for the program but thats just asking for issues and I dont want to have to manage anything a static folder is simple and already exists on my machine/in the source for any machine.

b. Yes I get that just like 0r0d but its much easier for me to work on a certain section that try to coordinate a compile time option across developers.

c. That would work and would be in my specific section (all compilation is on a linux machine so no worries im not familiar with symlinks in windows havent compiled or done anything other than games on it in a long time) I may fallback to this if I cant get Servants way to work.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0