Compilation errors in MSVC due to BLARGG_EXPORT __declspec(dllexport)

Issue #24 resolved
Former user created an issue

On many functions, BLARGG_EXPORT (expands to __declspec(dllexport) on MSVC2017) is only present in .cpp and not .h. This fails to compile on MSVC 2017.

According to https://msdn.microsoft.com/en-us/library/a90k134d.aspx and https://gcc.gnu.org/wiki/Visibility , export statements should present in headers, not .cpp files. Many of the errors I'm getting occur when BLARGG_EXPORT is present in .cpp. I'm not sure if it should be in both or not.

I also get errors related to extern const gme_type_t \n gme_ay_type, ... where BLARGG_EXPORT is present in .cpp but not .h.

Changing the definition of BLARGG_EXPORT to "nothing" fixed the problems for my use case (static linking).

Comments (4)

  1. Michael Pyne repo owner

    Hmm, I agree, these export statements should be in the headers. Hopefully it's an easy fix to automate.

  2. Michael Pyne repo owner

    Move BLARGG_EXPORT to header.

    The supported C++ compilers all prefer the BLARGG_EXPORT decl to be in the declaration instead of the defintion of a symbol (plus this allows the Windows dllimport/dllexport stuff to actually work as intended)

    Fixes Issue #24.

    → <<cset a3852f8ec8ef>>

  3. Michael Pyne repo owner

    I wasn't intending to "Resolve" this issue yet but if you could let me know if this pull request fixes the build on MSVC 2017 I'd appreciate it. If so I'll merge into master.

  4. Log in to comment