Society of Robots - Robot Forum
Software => Software => Topic started by: madsci1016 on August 14, 2010, 09:50:11 AM
-
I have several
#ifdef DEBUG
statements in a library file. I'd like to be able to activate those from my main c file without editing the library file. Is there a way to do that? I can't get it to work.
So the Main c file has
#define DEBUG
#include <library.h>
where library.h has all the ifdef statements in them. But this won't work, at least in the Arduino IDE. If i define DEBUG in the library header fille, then they all work.
-
Nevermind, i'm pretty sure I can't do what I want.
-
pre-processor directives only work at the point of generating the code.
So if the library is precompiled already then the '#defines' are now irrelevant.
Other alternative is build two libs - one with debug, one without. Then the user can choose which to link with. Only trouble is it means 'debug everything' or 'nothing'
-
So if the library is precompiled already then the '#defines' are now irrelevant.
Well, the library is not pre-compiled, like the .a files of webbotlib, unless you mean that the compiler first compiles any included source files before compiling the main .c file.
-
For arduino library, you need to delete the .o file in that library then you will able to get compiler re-compile that library.
-
I'll try that Bill, but i was making changes to the library .cpp file externally using notepad++ and just hitting compile in the Arduino IDE seemed to compile with any changes made, so i think it was running a fresh compile every time instead of just linking the binary.