error C2265: '<Unknown>' : reference to a zero-sized array is illegal
来源:互联网 发布:java连接cassandra 编辑:程序博客网 时间:2024/06/08 16:36
前言
今天要总结知识点, setsockopt and UDP_NOCHECKSUM, 突然发现编译不过.
在网上查了下解决方法, 自己分析了一下,人家为什么那么改. 学学人家分析解决问题的路子.
测试代码
// testcase.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <stdlib.h>#include <stdio.h>#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers#define _WIN32_WINNT 0x501 ///< if no this, error below/**\program files (x86)\microsoft visual studio\vc98\include\wspiapi.h(45) : error C2265: '<Unknown>' : reference to a zero-sized array is illegal*/#include <winsock2.h>#pragma comment(lib, "Ws2_32.lib")#include <windows.h>#include <Ws2tcpip.h> ///< 如果没定义 #define _WIN32_WINNT 0x501, 加了这个.h后报错/// Ws2tcpip.h的位置在 \Program Files (x86)\Microsoft Visual Studio\VC98\Include/// 去Ws2tcpip.h中看包含wspiapi.h的代码如下/**//// Unless the build environment is explicitly targeting only// platforms that include built-in getaddrinfo() support, include// the backwards-compatibility version of the relevant APIs.//#if !defined(_WIN32_WINNT) || (_WIN32_WINNT <= 0x0500)#include <wspiapi.h>#endif*//// 可以看出 只要_WIN32_WINNT > 0x500就可以不包含这个引起报错的头文件/// 这就是要定义 #define _WIN32_WINNT 0x501 的原因/// 从M$的注释看, wspiapi.h是为了兼容低版本Windows用的, /// 如果Widnows版本较高可以不包含此头文件/**win7 _WIN32_WINNT>=0x0601vista _WIN32_WINNT>=0x0600Windows XP _WIN32_WINNT>=0x0501 Windows 2000 _WIN32_WINNT>=0x0500 Windows NT 4.0 _WIN32_WINNT>=0x0400 Windows Me _WIN32_WINDOWS=0x0490 Windows 98 _WIN32_WINDOWS>=0x0410 *//// 从_WIN32_WINNT值含义可以看出, 如果编译出的PE运行在WinXp以上的Windows可以不用包含<wspiapi.h>int main(int argc, char* argv[]){ SOCKET s = INVALID_SOCKET; BOOL bVal = FALSE; /// 其它前置代码没写, 只测试 UDP_NOCHECKSUM 的写法 setsockopt(s, IPPROTO_UDP, UDP_NOCHECKSUM, (const char*)&bVal, sizeof(BOOL)); printf("Hello World!\n"); return 0;}
0 0
- \sdk\include\wspiapi.h(47) : error C2265: '<Unknown>' : reference to a zero-sized array is illegal
- \sdk\include\wspiapi.h(47) : error C2265: '<Unknown>' : reference to a zero-sized array is illegal
- error C2265: '<Unknown>' : reference to a zero-sized array is illegal
- \sdk\include\wspiapi.h(47) : error C2265: '<Unknown>' : reference to a zero-sized array is illegal
- error C2265: '<Unknown>' : reference to a zero-sized array is illegal
- \sdk\include\wspiapi.h(47) : error C2265: '<Unknown>' : reference to a zero-sized array is illegal 解
- \sdk\include\wspiapi.h(47) : error C2265: '<Unknown>' : reference to a zero-sized array is illegal 解
- wspiapi.h(45) : error C2265: '' : reference to a zero-sized array is illegal.
- error C2265: '' : reference to a zero-sized array is illegal解决办法
- reference to a zero-sized array is illegal解决办法
- Zero-sized Array
- error C2597: illegal reference to data member xxxx in a static member function
- error: reference to 'max' is ambiguous
- error: reference to 'left' is ambiguous
- Visual C++ Tips: error C2823: a typedef template is illegal
- 提示"illegal reference to data member'CPMAgentManageDlg::m_matrixMatrixSt'in a static member function"
- Error parsing reference: "Pxxxxxx" is not a valid repository/tag
- Reference To Array And Pointer To Array
- android 全透明式状态栏
- 上升子序列
- [查异常网]-20160405-我们到底为了什么钻研技术?
- Maven依赖管理
- android视图学习---Andriod的图形系统
- error C2265: '<Unknown>' : reference to a zero-sized array is illegal
- 用Java实现线性表的顺序存储结构
- Java Decorator
- 基于ZooKeeper的服务注册中心
- Java JDK测试
- Set1_Challenge1_Convert hex to base64
- jsp常用跳转方式
- 自平衡二叉搜索树:红黑树 VS AVL树
- 第三章:表达式与运算符