首页 > 解决方案 > 如何禁用警告“当前#pragma pack对齐值在包含文件中被修改”?

问题描述

我有一个使用 MSVC-2019 编译的 C++ Qt 项目。

并且编译器正在生成 warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack],因为pshpack1.h显然正在根据需要修改结构打包。

如何禁用警告? 鉴于它没有 W 编号。

#pragma warning (push)
#pragma warning (disable : 4200)            // warning about zero size arrays
#include <pshpack1.h>

typedef struct 
{
    char            table_pageno;
    unsigned short  table_count;
    unsigned char   table[];
} bad_block_info;

#include <poppack.h>
#pragma warning (pop)

标签: c++compiler-warnings

解决方案


推荐阅读