error C2143: syntax error : missing ';' before 'type'
来源:互联网 发布:intellij java doc 编辑:程序博客网 时间:2024/05/01 09:20
由于cpp编译下列代码报错
#include <cstdio>#include <cstring>int main(){ wchar_t wstr[] = L"Hello!"; int wlen = strlen(wstr); wprintf(L"%ls",wstr); int len; return 0;}
error C2664: 'strlen' : cannot convert parameter 1 from 'unsigned short [7]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
于是将后缀名改成.c
却出现另外一个诡异的编译错误:error C2143: syntax error : missing ';' before 'type' 并且指向 int len;这行
将代码做如下修改却诡异般的编译过了
#include <cstdio>#include <cstring>int main(){ wchar_t wstr[] = L"Hello!"; int len; int wlen = strlen(wstr); wprintf(L"%ls",wstr); return 0;}
不知道什么原因!!找了找资料。。。。原来It is a rule! 在纯C中,在一个代码块中变量声明必须在最前面
- error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing \';\' before \'type\'
- error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing ';' before 'type' in Visual C++
- 奇怪的 error C2143: syntax error : missing ';' before 'type'
- VC6.0 error C2143: syntax error : missing ';' before 'type'。。
- 【VC6.0】error C2143: syntax error : missing ';' before 'type'
- C语言 error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing ';' before '*'问题
- error C2143: syntax error : missing ';' before '*....
- error C2143: syntax error : missing ';' before '*.... 解决...
- error C2143: syntax error : missing ')' before '*'
- error C2143: syntax error : missing ';' before '*'
- 用户与组的应用
- Android ProgressBar 进度条
- CEGUI加载layout文件出错
- 为赋新词强说愁之五(兼职生活二)
- 什么是yacc?
- error C2143: syntax error : missing ';' before 'type'
- visual studio 2005没有找到MSVCR80D.dll问题
- 重新规划,希望是转机
- RHL配置VNC Server
- 诺基亚之死
- 藏书阁
- 如何制定有效的产品测试计划
- Android的View类使用
- 我们为何需要用户角色