Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What is this modification ('MY_MODULE_API') of class definition?

12 views
Skip to first unread message

fl

unread,
Oct 16, 2017, 11:19:34 AM10/16/17
to
Hi,

I know a class definition in general. When I see the below code snippet,
it is found there is a modification: 'MY_MODULE_API' after class keyword.
What is this thing?

Thanks in advance







//////////////
namespace gr {
namespace my_module {

/*!
* \brief <+description of block+>
* \ingroup my_module
*
*/
class MY_MODULE_API cognitive : virtual public gr::block
{
public:
typedef boost::shared_ptr<cognitive> sptr;

/*!
* \brief Return a shared_ptr to a new instance of my_module::cognitive.
*
* To avoid accidental use of raw pointers, my_module::cognitive's
* constructor is in a private implementation
* class. my_module::cognitive::make is the public interface for
* creating new instances.
*/
static sptr make();
};

} // namespace my_module
} // namespace gr

#endif /* INCLUDED_MY_MODULE_COGNITIVE_H */
--------------------
#ifdef gnuradio_my_module_EXPORTS
# define MY_MODULE_API __GR_ATTR_EXPORT
#else
# define MY_MODULE_API __GR_ATTR_IMPORT
#endif

Paavo Helde

unread,
Oct 16, 2017, 11:48:15 AM10/16/17
to
On 16.10.2017 18:19, fl wrote:
> Hi,
>
> I know a class definition in general. When I see the below code snippet,
> it is found there is a modification: 'MY_MODULE_API' after class keyword.
> What is this thing?
> class MY_MODULE_API cognitive : virtual public gr::block

Most probably this is a macro which expands to __declspec(dllexport) or
__declspec(dllimport) as needed, on Windows. See
https://msdn.microsoft.com/en-us/library/81h27t8c.aspx (featuring a
non-caps macro in the true MS style).


This stuff is necessary because of the peculiarities of how DLL linking
and name resolution works in Windows.
0 new messages