c - "expected'; ',' 或 'or' ) 'before' * 'token"使用结构时出错

标签 c struct compiler-errors

全部

我在使用结构时遇到一些问题。
源码如下所示。

main.c

#include <stdio.h>
#include "info.h"

_Rbuffer Rb;

void write(_Rbuffer Rb *rb)
{
    printf("write function\n");
}


void main(void)
{

    printf("Hello World\n");

}

信息.h

#include <stdint.h>

typedef struct
{
    uint8_t Button1;
} _Rbuffer;

extern _Rbuffer Rb;

编译时出现如下错误。

root@test-VirtualBox:~/sample# gcc main.c
main.c:6:24: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
 void write(_Rbuffer Rb *rb)
                        ^  
root@test-VirtualBox:~/sample# 

我目前无法更改 info.h。

我声明了一个结构体,但不知道为什么会发生错误。

如何解决这个问题?

最佳答案

1 您应该使用 int main 而不是 void main

2 您应该使用 void write(_Rbuffer *rb) 而不是 void write(_Rbuffer Rb *rb)

关于c - "expected'; ',' 或 'or' ) 'before' * 'token"使用结构时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44425491/

相关文章:

c++ - 如何为 Roland UM 4 实现 MIDI 驱动程序?

char数组中的C随机字符

c - 使用 (char *)malloc(0) 和 NULL 初始化字符串之间的区别

c - Linux、C、ncurses : seg fault caused by printw

c - 从双指针访问结构

c++ - C++结构的字段大小

c - 指针操作期间出现段错误

compiler-errors - 什么是 UndefvarError?

java - WEKA源代码编译有错误

vba - Tempvar的错误91 “Object not Set”