JUCE api macro?


#1

Hi all, since getting back into C++ and using the juce framework, I've seen a couple of things that I just don't recall from years ago.What is exactly is the JUCE api macro?  What's it's purpose?  Only reason I know it's a macro is because the tool tip tells me it is. 

I've used the #define many times in the past, but I don't recall ever seeing anything like this before.

class JUCE_API  Component  : public MouseListener


#2

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

JUCE_API ( https://github.com/julianstorer/JUCE/blob/master/modules/juce_core/system/juce_StandardHeader.h#L119 )


#3

I understand it's a macro, but, what is the reason for putting it between class and component?  


#4


I'm not sure to understand your question. 


Is it:


- About visibility in general?
- The position of the macro?
- Why JUCE classes have visibility attribute?
- Why a macro is used to define that attribute?

 

In case few links that respond to some of the question above.

Visibility attributes may be applied to functions, variables, templates, and C++ classes. If a class is marked as hidden, all of its member functions, static member variables, and compiler-generated metadata, such as virtual function tables and RTTI information, are also hidden.

http://gcc.gnu.org/wiki/Visibility

https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html


#5

Well, now that you mentioned it. The first three would be greatly apprecited. I understand the basics of macros, but don't undertand them fully enough to understand why JUCE is using them.  


#6


1. and 3. are well explained in the Apple link i put in my previous post.
2. TBH i don't know. That is Jules's personal taste.
4. This usage of macros is not specific to C++ nor JUCE. It is largely used for C code also. It uses conditional compilation ( http://www.eskimo.com/~scs/cclass/notes/sx9c.html ) for blocks of code, attributes of functions, function names called. In that case it controls the visiblity accordingly to the platform (Mac / Windows...) and the target (a DLL or an executable). It is commonly used also to modify function called for Release or Debug build process.