Weird ... Maybe one of the other includes is undefining USE_LOG again?
I would enable the option to force the preprocessor to write the preprocessed result to a file. Then open that file and maybe that might give a clue what's going on.
To enable that, right click the file in your solution explorer, click properties, go to C++ > Preprocessor and enable generate preprocessed file. It will create a file with extension .i which is just plain text.
Don't compile the whole project with this preprocessed file output enabled.
Enable the preprocessed file output for the file you want to investigate. Then right click that file and click compile to only compile that one file. It should generate a .i file which you can open in any text editor.
does it work with your original code ?
If so, it might be a problem with the library or with how you use it - is the log file open for writing ? are the function calls correct ? etc.
Weird ... Maybe one of the other includes is undefining USE_LOG again?
I would enable the option to force the preprocessor to write the preprocessed result to a file. Then open that file and maybe that might give a clue what's going on.
To enable that, right click the file in your solution explorer, click properties, go to C++ > Preprocessor and enable generate preprocessed file. It will create a file with extension .i which is just plain text.
Ok I did this and it's 52,000 lines long. Any clues as to what I'm looking for?
does it work with your original code ?
If so, it might be a problem with the library or with how you use it - is the log file open for writing ? are the function calls correct ? etc.
Regards,
Zachm
It does the same - nothing.. haha. Log file is there and will open and the function calls are correct. I'm 99% positive that it's the #define that is wrong.
Last edited by Mybowlcut; April 7th, 2009 at 10:10 AM.
50000 lines for one file? Geez I never knew so much was happening when I compile haha.
I couldn't find the replaced macro in there. I'm trying to enable it for main.cpp in the project that uses the static library where Logger is but I get this link error:
Code:
fatal error LNK1104: cannot open file '.\Debug\main.obj' Earth 1.2
Whenever I don't use the macro to access the Logger singleton, it works fine:
Maybe, your static library is compiled without _DEBUG defined? Try to recompile all the stuff of your project making sure _DEBUG is defined for each file. You can reach this by doing -D_DEBUG command line compiler option.
50000 lines for one file? Geez I never knew so much was happening when I compile haha.
I couldn't find the replaced macro in there.
Then try to find the place in the code where the logger line should have been and see what the preprocessor made of it. Also find the place where you had your include<logger.h> and see what exactly got included.
I forgot about this! I have attached a zip file containing a file's processor output that uses Logger.h. I found where the class declaration for Logger is (just going to post a snippet) and it doesn't seem that the #define in Logger.h is working:
Code:
#line 37 "c:\\documents and settings\\bill\\my documents\\visual studio 2005\\projects\\sdl_game_engine_1_1\\sdl_game_engine_1_1\\time.h"
#line 7 "c:\\documents and settings\\bill\\my documents\\visual studio 2005\\projects\\sdl_game_engine_1_1\\sdl_game_engine_1_1\\logger.h"
#line 14 "c:\\documents and settings\\bill\\my documents\\visual studio 2005\\projects\\sdl_game_engine_1_1\\sdl_game_engine_1_1\\logger.h"
class Logger
{
public:
static void Initialise(const std::string& file_name);
This is what the actual code for the above looks like:
Code:
#include <time.h>
#include <vector>
#ifdef USE_LOG
#define LOG(string) Logger::Get().Log(string)
#else
#define LOG(string)
#endif
// Singleton designed to log application and game details to
// aid in difficult bugs and errors.
class Logger
{
public:
static void Initialise(const std::string& file_name);
The LOG macro was actually called by the code in the project that uses the project that Logger is in but this is what the processor thought of it:
So what's going wrong? _DEBUG macro not working? _DEBUG is in my preprocessor options in both projects (as it should be by default for debug configurations). I think it's not seeing the USE_LOG define:
Insert it "everywhere", before and after including Logger.h for instance. Try even thing you _know_ shouldn't be a problem like LOGGER_H, USE_LOG and so on. Macros can provide such an headache...
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.