This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Inline C Functions

Any hope of adding the inline keyword to the C51 compiler so that
we can declare functions as inline? For example, I have a C source
file that wraps manipulations to the 8051 itself. Some functions are
nothing more than:

void cntrl_MaskAllInterrupts(void)
{
EA = 0;
}

I'd like it so that the compiler could inline this function so I don't
get the function call and return overhead.

Any chance?

Parents
  • Any hope of adding the inline keyword to the C51 compiler so that
    we can declare functions as inline?


    That would be nice, wouldn't it. But no, we can't do that (yet?).

    void cntrl_MaskAllInterrupts(void)
    {
        EA = 0;
    }

    This one is very easy.

    sbit r_enable_interrupts = 0xAF; // IE.EA,  Enable All unmasked interrupts
    void enableInterrupts(void)
    {
        r_enable_interrupts = !0;
    }
    void disableInterrupts(void)
    {
        r_enable_interrupts = 0;
    }

    Take a look at what's in intrins.h in the Keil include directory. Remember, all SFR's in the 8051 are directly accessible in C.

    - Mark

Reply
  • Any hope of adding the inline keyword to the C51 compiler so that
    we can declare functions as inline?


    That would be nice, wouldn't it. But no, we can't do that (yet?).

    void cntrl_MaskAllInterrupts(void)
    {
        EA = 0;
    }

    This one is very easy.

    sbit r_enable_interrupts = 0xAF; // IE.EA,  Enable All unmasked interrupts
    void enableInterrupts(void)
    {
        r_enable_interrupts = !0;
    }
    void disableInterrupts(void)
    {
        r_enable_interrupts = 0;
    }

    Take a look at what's in intrins.h in the Keil include directory. Remember, all SFR's in the 8051 are directly accessible in C.

    - Mark

Children