我有一个C主文件,其中包括此.h文件:
#pragma pack(1)
#ifndef PACKAGE
#define PACKAGE
struct A {
uint8_t a;
uint8_t b;
uint64_t c;
} typedef A;
#endif
Run Code Online (Sandbox Code Playgroud)
编译警告后:
myfile.c:28:10: warning: the current #pragma pack alignment value is modified in
the included file [-Wpragma-pack]
#include "structures.h"
^
./structures.h:1:9: note: previous '#pragma pack' directive that modifies
alignment is here
#pragma pack(1)
Run Code Online (Sandbox Code Playgroud)
出现。
我不明白我的代码有什么问题。有什么办法可以删除此警告?
这是一个完整的示例:
这是一个名为“ myfile.c”的简单C文件:
#include "structures.h"
int main(){
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是一个名为“ structures.h”的.h文件:
#include <stdlib.h>
#include <stdio.h>
#pragma pack(1)
#ifndef PACKAGE
#define PACKAGE
struct A {
uint8_t …Run Code Online (Sandbox Code Playgroud)