Closed suikan4github closed 1 month ago
This is the actual implementation.
MSVC also needs weak binding. Otherwise, the test program is unable to compile. On the other hand, MSVC doesn't have weak binding. So, we use alternatename pragma. The alternatename is a kind of alias that works only when the target symbol is unavailable. So, this is weak binding.
The alternatename is the command of the linker. So, we need to think of the symbol as a link phase. In the 32-bit MVS compile, the C symbol will have an extra "" at the head of the symbol. in the 64-bit MSVC compile, there is no extra "".
extern "C" void gpio_put(uint gpio, bool value);
#if defined(__GNUC__) || defined(__clang__)
__attribute__((weak)) void gpio_put(uint gpio, bool value)
#elif defined(_MSVC_VER)
#if defined(_M_IX86) // MSVC for x86
#pragma comment(linker, "/alternatename:_gpio_put=__weak_gpio_put")
#elif defined(_M_AMD64) // MSVC for AMD64
#pragma comment(linker, "/alternatename:gpio_put=_weak_gpio_put")
#endif // _MSVC_VER
void _weak_gpio_put(uint gpio, bool value)
#else
#error "Unknown compiler."
#endif
{
assert(false &&
"Error : The hardware_gpio library is missing in the link phase.");
}
Fixed. Merged to develop. Ready to release.
See the result of the action.
https://github.com/suikan4github/rpp_driver/actions/runs/11283140455/job/31381988605
We have an error message like this :
The weak binding is required only for the pico platform. So, we can skip it by #if #endif.