[flac-dev] os/2 support using Watcom

Ozkan Sezer sezeroz at gmail.com
Mon Jan 23 23:59:40 UTC 2017


On 1/24/17, Dave Yeo <dave.r.yeo at gmail.com> wrote:
> On 01/23/17 01:01 AM, Erik de Castro Lopo wrote:
>> Dave Yeo wrote:
>>
>>> >GCC supports __declspec(dllexport) though it still needs a def file,
>>> >with no exports. Libtool doesn't currently and as flac uses libtool...
>> So you're happy with this patch?
>>
>>      http://lists.xiph.org/pipermail/flac-dev/2017-January/006170.html
>>
>
> No. Lots of errors such as
> ../../include/FLAC/export.h:77:18: error: expected identifier or '(' before
> ')' token
>  #define FLAC_API __declspec(__cdecl)
> ...
> as GCC doesn't like the __cdecl macro.

Well, you were the one who suggested __declspec(__cdecl)
(history for Eric:  my original patch in the first mail in this thread
didn't have __cdecl,  Dave wanted watcom and emx-gcc built
binaries to be compatible, so I suggested the second version.)

However, I see what's going on: gcc is possibly expecting the
calling convention specifier attribute between the type and the
funcname. (which can be fixed but in a way intrusive to all the
headers, such as by inventing and using a FLAC_CALL macro..)

>
> If going this route then perhaps,
>
> diff --git a/include/FLAC/export.h b/include/FLAC/export.h
> index d52f0bb..5d40421 100644
> --- a/include/FLAC/export.h
> +++ b/include/FLAC/export.h
> @@ -66,6 +66,13 @@
>  #define FLAC_API __declspec(dllimport)
>  #endif
>
> +#elif defined(__OS2__)
> +#if defined(FLAC_API_EXPORTS) && defined(__WATCOMC__) && defined(__SW_BD)
> +#define FLAC_API __declspec(__cdecl) __declspec(dllexport)
> +#else
> +#define FLAC_API __declspec(dllexport)

You had said that dllexport alone is not OK with emx-gcc, and
besides dllexport at that place is wrong: you want dllexport when
building flac as a dll (__SW_BD from Watcom tells us that and we
are sure because we defined FLAC_API_EXPORTS ourself.)
That line must either be calling convention (which you reported
fails with gcc) or it should be an empty define.

One solution is making that line an empty define for gcc and
__cdecl for Watcom.

> +#endif
> +
>  #elif defined(FLAC__USE_VISIBILITY_ATTR)
>  #define FLAC_API __attribute__ ((visibility ("default")))
>
> Another option is for the caller to define FLAC_API, eg
> #define FLAC_API __declspec(__cdecl)
> #include <flac\all.h>
>
> diff --git a/include/FLAC/export.h b/include/FLAC/export.h
> index d52f0bb..07cfe59 100644
> --- a/include/FLAC/export.h
> +++ b/include/FLAC/export.h
> @@ -56,6 +56,7 @@
>   * \{
>   */
>
> +#ifndef FLAC_API
>  #if defined(FLAC__NO_DLL)
>  #define FLAC_API
>
> @@ -66,6 +67,10 @@
>  #define FLAC_API __declspec(dllimport)
>  #endif
>
> +#elif defined(__OS2__)
> +#define FLAC_API __declspec(dllexport)
> +#endif
> +
>  #elif defined(FLAC__USE_VISIBILITY_ATTR)
>  #define FLAC_API __attribute__ ((visibility ("default")))
>
> @@ -73,7 +78,7 @@
>  #define FLAC_API
>
>  #endif
> -
> +#endif
>  /** These #defines will mirror the libtool-based library version number,
> see
>   *
> http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
>   */
>
> This assumes that Ozkan isn't pursuing his OpenWatcom patches which isn't
> clear.

Well I'm bored.  You guys decide.


More information about the flac-dev mailing list