free-audio / clap

Audio Plugin API
https://cleveraudio.org/
MIT License
1.79k stars 102 forks source link

Add explicit calling conventions to all function pointers #154

Closed robbert-vdh closed 2 years ago

robbert-vdh commented 2 years ago

This addresses the problem described in #153. Without this systems with multiple calling conventions (like x86 Windows, or a future platform) may not use the correct calling convention when calling these functions. And even if the correct calling convention is used, calling these functions would still be undefined behavior as the default calling convention depends on the compiler. It's also required for being able to use CLAP in a Winelib setup, as the __cdecl calling convention tells GCC to use the Microsoft x64 ABI for those functions.

baconpaul commented 2 years ago

So this changes

int64_t (*read)

to

int64_t(CLAP_ABI *read)

losing the space after int64_t

Can we get the space back?

robbert-vdh commented 2 years ago

That's part of the highly customized .clang-format configuration added by @abique. I just reformatted everything (except for the couple of other things in the repo that aren't correctly formatted right now) according to those rules.

robbert-vdh commented 2 years ago

I googled for a bit and I couldn't find a way to customize this in clang-format without adding spaces before every paren (which is definitely not what we want here). Maybe it's just an oversight in clang-format?

baconpaul commented 2 years ago

That's part of the highly customized .clang-format configuration added by @abique. I just reformatted everything (except for the couple of other things in the repo that aren't correctly formatted right now) according to those rules.

Ahh right because this change made it look like a function name with typed argument as opposed to a function pointer. Harumph.

abique commented 2 years ago

Yo, Thank you very much for picking this up! If you need to improve .clang-format feel free to do it :-) Cheers, Alex