error C141: syntax error near 'void', expected '__asm'

遇到了一个问题提示 error C141: syntax error near 'void', expected '__asm'真的不知道该怎么解决了,诚恳求解!

#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar temp;
void delay(uint);
void main()
{
temp=0xfe;

P1=temp;
    while(1)
    {
        temp=_crol_(temp,1);
        delay(50);
        P1=temp;
    }

void delay(uint z)
{
uint x,y;
for(x=100;x>0;x--)
{
for(y=z;y>0;y--)
{
}
}
}
}


就是delay位置错了,delay函数不能放在main函数里面,所有函数都不可以这样子。还有函数声明需要一样。给你改了一下。


#include <reg52.h>
#include <intrins.h>
#define uint32_t unsigned int
#define uint8_t  unsigned char

uint8_t temp;
void delay(uint32_t z);

void main(void)
{
    temp = 0xfe;

    P1 = temp;
    while(1)
    {
        temp = _crol_(temp,1);
        delay(50);
        P1 = temp;
    }
}

void delay(uint32_t z)
{
    uint32_t x, y;
    for(x = 100; x > 0; x--)
    {
        for(y = z; y > 0; y--)
        {
            ;
        }
    }
}

把delay函数放到main函数外面