gpt4 book ai didi

c++ - 查找预编译头使用时跳过头文件

转载 作者:太空狗 更新时间:2023-10-29 20:05:04 25 4
gpt4 key购买 nike

你能帮我理解问题出在哪里吗?我似乎包含了 stdafx.h。然后我尝试重建解决方案。试图清洁解决方案。无论如何我得到这个:

c:\...\tetris\figure_factory.cpp(2): warning C4627: '#include "figure_factory.h"': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\...\tetris\tetris\figure_factory.cpp(3): warning C4627: '#include "figure.h"': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header

当然还有由于缺少头文件而导致的全套错误。

我的文件:

figure_factory.cpp


#pragma once
#include "figure_factory.h"
#include "figure.h"
#include "stdafx.h"
#define stop __asm nop

Figure I;
I.shape = {
{{0, 0, 0, 0},
{1, 1, 1, 1},
{0, 0, 0, 0},
{0, 0, 0, 0}},
......



figure_factory.h

#pragma once
#include "figure.h"
#include "stdafx.h"
#define stop __asm nop


class Figure_Factory{
const int figure_number = 5;
const int colour_number = 5;

public:
Figure get_figure(int type, int colour);
}

最佳答案

stdafx.h 如果您使用预编译 header 和 Microsoft 编译器,则必须作为第一个包含文件。并且您不得将其包含在其他包含文件中。而#pragma once.cpp文件中是没用的

关于c++ - 查找预编译头使用时跳过头文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15589636/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com