编译器使用结构体时出错C2143 [英] Compiler Error C2143 when using a struct

查看:265
本文介绍了编译器使用结构体时出错C2143的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编译一个简单的.c在视觉c + +编译为C代码(/ TC)
和我得到这个编译错误

I'm compiling a simple .c in visual c++ with Compile as C Code (/TC) and i get this compiler error


错误C2143:语法错误:缺少';'before'类型

error C2143: syntax error : missing ';' before 'type'

struct

 struct foo test;

同样适用于使用struct的typedef。

same goes for using the typedef of the struct.


错误C2275:'FOO':非法使用此类型作为表达式

error C2275: 'FOO' : illegal use of this type as an expression


推荐答案

我忘了在C你必须声明所有的变量之前的任何代码。

I forgot that in C you have to declare all your variables before any code.

这篇关于编译器使用结构体时出错C2143的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆