https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119414

--- Comment #17 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Robert Dubner from comment #16)
> Mainframe programmers sometimes think differently, I believe.
> 
> If my understanding from discussions with an old-school mainframe programmer
> -- who admittedly hasn't  coded in many years -- are correct, they happily
> do things like
> 
>      CALL "get-power-from-windmill"
>       ON EXCEPTION
>         CALL "get-power-from-waterwheel"
>         END-CALL
>      END-CALL

This is very much expected to work on modern (at least, 2000+) era *nix.

__attribute__((__weak__))
void get_power_from_windmill ();
__attribute__((__weak__))
void get_power_from_waterwheel ();


 if (get_power_from_windmill) {
   get_power_from_windmill ();
 } else if (get_power_from_waterwheel) {
   get_power_from_waterwheel ();
 } else {
   printf ("warning: unlicensed hamster in use");
 }

For serious example, macOS uses this mechanism so that applications that do not
absolutely depend on some new feature can be deployed onto older OS versions
(that might not have that new feature).

Reply via email to