Help with headers


#1

Hi all,

I'm a bit new to the C++ world and I'm using JUCE in my first big project. I saw that there are no #include "header" in any of the juce cpp, but I'm not able to figure out how is done this, the thing is that I would like to do the same in my project and I don't know how to start. I saw the "class JUCE_API SomeClass" but it is not very clear to me why this is ussed that way.

Can anybody help my with this issue?

 

Thanks in advance


#2

Each module in JUCE contains an amalgamated file version. For instance in the "juce_core" folder there is a "juce_core.cpp" file that contains everything for that module,

( https://github.com/julianstorer/JUCE/blob/master/modules/juce_core/juce_core.cpp#L112 ).


#3

Why it is a cpp instead of a .h?


#4

http://buffered.io/posts/the-magic-of-unity-builds/


#5


Because it's not an header but a regular cpp files that needs to be built. The include directive is more or less just a copy/paste function. 

Instead of linking against a pre-builded library, or compile hundreds of files (with the mess that could result), you just use few files and a couple of headers. That way makes also the "Obj-C / C++" compiler platform switch easy. 

That way is designed to fit well "The Introjucer" workflow. The app sets all the configs for you. At first it can be surprising. But finally IMHO that's great (without pitfalls if you strip the dead code in the executable produced). 
 


#6

Then, what it the goal of JUCE_API ?


#7

Then, what it the goal of JUCE_API ?

This question has come up before:

http://www.juce.com/forum/topic/what-exactly-do-juceapi-and-jucecalltype-do

http://www.juce.com/forum/topic/juce-api-macro

There are even more threads that discuss JUCE_API; you can search the JUCE forum if you are interested further.