error C2275: ‘XXX’ : illegal use of this type as an expression 报错的解决方法!
2014-09-04 20:19
806 查看
//最简单的创建多线程实例 #include<stdio.h> #include<windows.h> //子线程函数 DWORD WINAPI ThreadFun(LPVOID pm) { printf("子线程的线程ID号为:%d\n 子线程输出Hello World\n",GetCurrentThreadId()); return 0; } //主函数,所谓主函数其实就是主线程执行的函数 int main() { //HANDLE handle=CreateThread(NULL,0,ThreadFun,NULL,0,NULL); printf("最简单的创建多线程实例\n"); printf("--by MoreWindows(http://blog.csdn.net/MoreWindows)--\n\n"); HANDLE handle=CreateThread(NULL,0,ThreadFun,NULL,0,NULL); WaitForSingleObject(handle,INFINITE); //WaitForSingleObject(CreateThread(NULL,0,ThreadFun,NULL,0,NULL),INFINITE); return 0; }
代码没问题
怀疑是纯C环境 比较老的版本
所以要求变量定义只能在开头
//最简单的创建多线程实例 #include<stdio.h> #include<windows.h> //子线程函数 DWORD WINAPI ThreadFun(LPVOID pm) { printf("子线程的线程ID号为:%d\n 子线程输出Hello World\n",GetCurrentThreadId()); return 0; } //主函数,所谓主函数其实就是主线程执行的函数 int main() { HANDLE handle=CreateThread(NULL,0,ThreadFun,NULL,0,NULL); printf("最简单的创建多线程实例\n"); printf("--by MoreWindows(http://blog.csdn.net/MoreWindows)--\n\n"); //HANDLE handle=CreateThread(NULL,0,ThreadFun,NULL,0,NULL); WaitForSingleObject(handle,INFINITE); //WaitForSingleObject(CreateThread(NULL,0,ThreadFun,NULL,0,NULL),INFINITE); return 0; }
这样编译器就没有报错了。
相关文章推荐
- error C2275 illegal use of this type as an expression 解决方法
- error C2275: "xxx"illegal use of this type as an expression
- error C2275: 'xxx' : illegal use of this type as an expression
- error C2275: 'xxx' : illegal use of this type as an expression
- error C2275: 'xxx' : illegal use of this type as an expression
- error C2275: 'time_t' : illegal use of this type as an expression
- 'FILE' : illegal use of this type as an expression编译错误的解决
- error C2275 : 'UNICODE_STRING' :illegal use of this type as an expression
- error C2275! illegal use of this type as an expression
- 'FILE' : illegal use of this type as an expression编译错误的解决
- 编译选项引发的ERROR C2275:illegal use of this type as an expression
- error C2275: 'FILE' : illegal use of this type as an expression
- C语言编程调试:illegal use of this type as an expression错误解决办法
- 'FILE' : illegal use of this type as an expression编译错误的解决
- error C2275: 'FILE' : illegal use of this type as an expression
- VC6.0中出现的“illegal use of this type as an expression”错误及其解决办法
- illegal use of this type as an expression
- illegal use of this type as an expression
- 'PIO_STACK_LOCATION' : illegal use of this type as an expression
- 'PIO_STACK_LOCATION' : illegal use of this type as an expression