Say for example I wanted to add a file that had some useful constants (constants.h) and I wanted to place it inside tracktion_engine\modules\tracktion_engine\plugins\internal. How might I accomplish this? For various reasons you’re welcome to deem as dubious I want these constants to appear in the trakction::engine namespace, and to be available to any file that has included JuceHeader.h.
I have tried to do this, and seem to be managing to make my Visual Studio project to be happy, insofar as intelisense can find definitions and so forth, but when I go to build I get linker errors for anything declared within constants.h. From what I have been able to gleam including constants.h in tracktion_engine/tracktion_engine.h is part of the trick, but I suspect that because Projucer has not been informed of the change it won’t know how to create build instructions for the symbols defined within constants.h, and so the linker will be sad . It’s not clear to me from looking at the module files nor the settings in Projucer how to meaningfully edit the tracktion_engine module so that the JuceHeader.h file automatically includes my addition and the project builds as expected.
Thanks for your time,
I’m not sure why you would want to put a file inside tracktion_engine?
Nothing inside tracktion_engine will depend on it so why not just keep it as one of your own source files?
dave 96, I see you have deemed my reasons as dubious! I would like to make the engine behave differently.
Fork the traction engine repo
I’m not really sure I understand the problem.
Just follow the pattern of one of the hundreds of files in the repo?
If you’re getting linker errors, it would help to know what they are. My best guess is they’re multiple definition errors because you haven’t marked a definition inline in a header file?
Ok, that’s a useful hint! I’ll investigate that tomorrow, thanks for your help.
Fixed! Here’s what I learned:
When inheriting one of the tracktion_engine plugin classes, the order of includes in tracktion_engine.h as well as the forward declarations of any classes or structs is important. The JuceHeader.h file is handy in that it makes using Juce modules easier – it provides one include and one namespace to take care of all things tracktion, but it also means that where the include or the tracktion::engine namespace is used there’s chance to have objects asked for prior to their appearance in the JuceHeader.h maze of includes. This isn’t a problem, and it’s not wrong, it’s just something to think about while making these kinds of modifications.
@Dave96, your answer was helpful to me because your baffled disposition showed me that I had made some incorrect assumptions about the problem. Sometimes when you ask a question that makes no sense it’s most helpful to get a no sense answer back because it reveals where your misconceptions lay. In the end issue had nothing to do with inlines, but your lack of concern for Projucer prompted me to think more closely about compilation order.