1.8.3 Using $Sub$$ to mix semihosted and nonsemihosted I/O functionality

You can use $Sub$$ to provide a mixture of semihosted and nonsemihosted functionality.

For example, given an implementation of fputc() that writes directly to a UART, and a semihosted implementation of fputc(), you can provide both of these depending on the nature of the FILE * pointer passed into the function:

int $Super$$fputc(int c, FILE *fp);
int $Sub$$fputc(int c, FILE *fp)
    if (fp == (FILE *)MAGIC_NUM) // where MAGIC_NUM is a special value that
    {                            // is different to all normal FILE * pointer
                                 // values.
        return c;
        return $Super$$fputc(c, fp);
Non-ConfidentialPDF file icon PDF versionARM 100073_0608_00_en
Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved.