Detect if game is build in debug or release mode?
Detect if game is build in debug or release mode?
hi
have been wondering if it was possible to detect in ur program whether or not you build your code in debug or release mode? so say if it was in debug mode it would allow for to turn things like godmode on and off, but when it build in release that wouldn't be possible?
I suppose i could just have a variable called debug or something that i could set to true while testing and false when for when building for release, but I'd love if it could be done automatic somehow
have been wondering if it was possible to detect in ur program whether or not you build your code in debug or release mode? so say if it was in debug mode it would allow for to turn things like godmode on and off, but when it build in release that wouldn't be possible?
I suppose i could just have a variable called debug or something that i could set to true while testing and false when for when building for release, but I'd love if it could be done automatic somehow
Re: Detect if game is build in debug or release mode?
I'm pretty sure debug mode only works in your IDE. The actual .exe that you get and would send to other people would be the release mode, I think.
If you wanted there to be some way that only you could turn things like godmode on or off then maybe you would want to use a if statement at the beginning of the program to check if you're "admin" or something or have the program prompt you for a password?
I'm not sure if this is the best solution because I'm just a beginner myself, but yeah.
If you wanted there to be some way that only you could turn things like godmode on or off then maybe you would want to use a if statement at the beginning of the program to check if you're "admin" or something or have the program prompt you for a password?
I'm not sure if this is the best solution because I'm just a beginner myself, but yeah.
Re: Detect if game is build in debug or release mode?
If what I've understood is right, then debug buid mode inserts some extra lines of code into ur program in order to give u error messages and stuff, so i teori it should be possible, but I don't know how.
I could also imagine that it would be different from compiler to compiler, but again I'm just guessing here
I could also imagine that it would be different from compiler to compiler, but again I'm just guessing here
Re: Detect if game is build in debug or release mode?
A quick google, and turns out there is. I think....
Have a look: Link
Have a look: Link
ʕ •ᴥ•ʔ
Re: Detect if game is build in debug or release mode?
great thanks
I did try to google it, but I couldn't find anything
I did try to google it, but I couldn't find anything
Re: Detect if game is build in debug or release mode?
If you use the #define macro NDEBUG together with the #ifdef or #ifndef preprocessor directives, you can create code that conditionally compiles depending on which build configuration you have selected. So you can make it so that the god mode or whatever doesn't get included in the Release configuration.
Chili
Re: Detect if game is build in debug or release mode?
Hi,
The way I would do this is to create a bool linked to a key on your keyboard.
bool Godmode=false;
Then you just stick an if statement in to turn on godmode if you press say F9.
You can easily remove this when you make the release version.
A lot of full commercial games leave it in when it goes to release like in the old Doom where you can turn on things to walk through walls and stuff.
Asimov
The way I would do this is to create a bool linked to a key on your keyboard.
bool Godmode=false;
Then you just stick an if statement in to turn on godmode if you press say F9.
You can easily remove this when you make the release version.
A lot of full commercial games leave it in when it goes to release like in the old Doom where you can turn on things to walk through walls and stuff.
Asimov
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk
Re: Detect if game is build in debug or release mode?
yes that's what along the idea of what I'm planning asimov, but I'd like to be able to lock it so that players can't abuse it - which I can easily do through a bool called debugMode and when that's true it allow for different debug options, such as godmode or a debugging screen with different infomation.
BUT I know myself well enough to know that I'm gonna forget to set that to false when building for release, so if I could create a way that would automaticly detect it that would be really great
So I've set up a little test, of how I've understood it should be, but it doesn't appear to be working
idea is that it'll tell me when it's on debug and when it's on release, but it always tells me it's debugging, so obiously I've misunderstood how I'm suppose to use this ^^'
BUT I know myself well enough to know that I'm gonna forget to set that to false when building for release, so if I could create a way that would automaticly detect it that would be really great
So I've set up a little test, of how I've understood it should be, but it doesn't appear to be working
Code: Select all
#include <iostream>
using namespace std;
#ifdef NDEBUG
#define debugMode false;
#else
#define debugMode true
#endif
void main()
{
if( debugMode )
{
cout << "Debug" << endl;
}
else
{
cout << "Release" << endl;
}
cin.get();
}
Re: Detect if game is build in debug or release mode?
Lose the semicolon:
#define debugMode false;
#define debugMode false;
Chili
Re: Detect if game is build in debug or release mode?
same result as before - telling me it's debug in both debug and release build configuration
from my experience it doesn't actully seem to matter whether or not there is a ; after a preprocessor (think that's what they're called right?)
from my experience it doesn't actully seem to matter whether or not there is a ; after a preprocessor (think that's what they're called right?)