Closed leo60228 closed 2 years ago
@leo60228 thanks for this info. I'll check if this can be implemented into the package.
@leo60228 Frankly speaking I have no idea what "_Generic" means or how it compiles (yet). But it seems work. I'll see how to add it into the package.
_Generic is a relatively new feature (C99 had polymorphic functions in the standard library, but those were implemented in a compiler-specific way until C11). SDCC supports it but there's several open bugs. I don't think it's usable for print
yet, but it could be with some bugfixes, and might be useful for other functions.
@leo60228 Sorry I ask the question before I learn some basics about _Generic. Why you think it is not usable for print? It seems my sketch compiles and works as expected.
There's a cryptic compiler error if you use it with a pointer, which is why char* was commented out. I linked an existing bug report for this in the original issue.
On Wed, Sep 29, 2021, 9:13 AM Deqing Sun @.***> wrote:
@leo60228 https://github.com/leo60228 Sorry I ask the question before I learn some basics about _Generic. Why you think it is not usable for print? It seems my sketch compiles and works as expected.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DeqingSun/ch55xduino/issues/54#issuecomment-930163578, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB7X32PG37EFDPVLKK5WBB3UEMGJHANCNFSM5E6UQG2Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
@leo60228 Thank you and I get it when trying to use the pointer.
Internal error: validateLink failed in SPEC_NOUN(type) @ /Users/sdcc-builder/build/sdcc-build/orig/sdcc/src/SDCCast.c:5401: expected SPECIFIER, got DECLARATOR
I'll subscribe to that ticket and see when it get fixed. Not supporting pointer makes implementing the _Generic to print pointless.
Update: The bug fixing is now funded. Wish it get fixed soon
Generic is functional after SDCC commit 13402.
This repo now supports Generic for print.
According to the README:
C11 adds
_Generic
for this purpose. Here's a trivial example: https://godbolt.org/z/Yv8sznf3vHowever, this currently can't be used for
print
due to an SDCC bug.