简体   繁体   English

语法错误:缺少';' 在“类型”之前

[英]syntax error : missing ';' before 'type'

I'm working with OPNET modeler and I inject code to improve my scenario. 我正在与OPNET Modeler合作,并注入代码来改善自己的情况。 when I compile code this message appeared syntax error : missing ';' 当我编译代码时,此消息出现语法错误:缺少';' before 'type' but it refer to transition that don't have any line of code. 在“类型”之前,但它指的是没有任何代码行的过渡。

What's the problem? 有什么问题?

please, Can anyone help me? 请,有人可以帮我吗?

That error message indicates that you have a missing semicolon. 该错误消息表明您缺少分号。 The most common place this happens is something like the following: 发生这种情况的最常见的地方如下:

class Foo {

    // ...

} // <-- NEED SEMICOLON HERE

int main() {
   // ...
}

Note that your class declaration may appear in a header file instead of a .cpp file. 请注意,您的class声明可能出现在头文件中,而不是.cpp文件中。

This error can also occur for some strict compilers if you declare and assign a variable in the same breath. 如果在同一时间声明和分配变量,对于某些严格的编译器也可能发生此错误。 This can be solved by changing foo_t my_var = old_var; 这可以通过更改foo_t my_var = old_var;来解决foo_t my_var = old_var; and splitting up the statement into 并将语句分为

foo_t my_var;
my_var = old_var;

Ludicrously, some compilers even throw an error if you don't put your variable declarations at the top of the code block.[1] 可笑的是,如果您不将变量声明放在代码块的顶部,则某些编译器甚至会引发错误。[1]

[1] http://social.msdn.microsoft.com/forums/en-US/vclanguage/thread/974f1b6a-7bad-4be7-a93e-66e6b2f18842 [1] http://social.msdn.microsoft.com/forums/zh-CN/vclanguage/thread/974f1b6a-7bad-4be7-a93e-66e6b2f18842

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM