3

問題が何であるかを理解するのを手伝ってもらえますか? を含んでいるようです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);
}
4

2 に答える 2

7

stdafx.hプリコンパイル済みヘッダーと Microsoft コンパイラを使用している場合は、最初のインクルード ファイルとして指定する必要があります。また、他のインクルード ファイルに含めてはなりません。そして、ファイル#pragma onceでは役に立たない.cpp

于 2013-03-23T17:14:38.037 に答える
1

別の可能性があります: ソース ファイルとしてマークされたヘッダー ファイルがあります。Visual Studio でヘッダー ファイルを右クリックし、[構成プロパティ] > [全般] > [アイテム タイプ] で、「C/C++ コンパイラ」ではなく「C/C++ ヘッダー」があることを確認します。

これは、<ClInclude> の代わりに <ClCompile> と入力して、.vcxproj ファイルを手動で編集するときに犯しやすい間違いです。

于 2016-04-21T10:54:15.330 に答える