2

I want to have a define from my sketch be picked up by a library. Here is a similar question for references: Using #define and multiple classes

I have a CI server that compiles my arduino sketchs on commmit. It pulls all my personal libs from an other repository and compiles the sketch using arduino-builder.

Now i want it to also make a debug build. (Some of my library's have debugstatments in them i enable using a #define debugsomething.

Is there any way i can get the compiler to pickup the #define in the sketch or am i better off making a very complex build script that modifies the headers between builds?

1 Answer 1

2

You need a common place that the building of all the places can get the definition from.

That isn't the sketch. The sketch is one of the things that would have to look at that common place.

That can either be a single shared header that everything else (that needs it) includes, or it can be a -D flag added to the compilation command.

For instance, adding:

-DDEBUG=1

to your compilation command is the same as adding

#define DEBUG 1

to every single file you compile.

8
  • Thanks for the replay. The -D options looks great for my purpose. Do you have any clue how to do this with github.com/arduino/arduino-builder?
    – Pimmetje
    Apr 29, 2016 at 7:33
  • I haven't a clue. Never used arduino-builder, and I don't speak "go", so I can't even work out what it's supposed to be doing. The lack of documentation makes it impossible to know how to actually use it, as well.
    – Majenko
    Apr 29, 2016 at 10:25
  • I made a issue over there. Hope they can help me : github.com/arduino/arduino-builder/issues/138
    – Pimmetje
    Apr 29, 2016 at 15:23
  • Can i also do multiple defines with one -D argument? Looks to me something does wrong when i try multiple -D arguments see issue 138
    – Pimmetje
    May 1, 2016 at 14:43
  • You can use as many -Dxxx=yyy arguments as you like.
    – Majenko
    May 1, 2016 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.