Skip to content

Visual Studio compatibility #17

@wo80

Description

@wo80

I was trying to compile the Vamp plugin from Essentia, running into the problem with the missing __declspec(dllexport). As described in README.msvc, I had to edit the vamp.h header to match Essentias linkage specification, see examples/vampplugins.cpp (ESSENTIA_API expands to __declspec(dllexport))

I was wondering if you'd accept a pull request to make this work out of the box. While the following section of the README.msvc isn't wrong

This is not present by default, because it isn't portable among compilers and, as we only want one symbol exported, the above linker option works equally well without code changes.

the problem is fairly easy to solve in a portable manner. The commonly used solution looks something like

#if (defined(_WIN32))
#   ifdef VAMP_NODLL
#       define VAMP_API
#   else
#       ifdef VAMP_API_IMPORTS
#           define VAMP_API __declspec(dllimport)
#       else
#           define VAMP_API __declspec(dllexport)
#       endif
#   endif
#else
#   if __GNUC__ >= 4
#       define VAMP_API __attribute__ ((visibility("default")))
#   else
#       define VAMP_API
#   endif
#endif

const VAMP_API VampPluginDescriptor *vampGetPluginDescriptor
    (unsigned int hostApiVersion, unsigned int index);

On Windows, this automatically sets the required export attribute. Please let me know whether I should do a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions