Visual Studio 2012で複数のCppファイルを作成しようとしましたが、コード部分は次のとおりです。
externTest.ccp
// externTest.cpp : Defines the entry point for the console application.
//
#include "...\externTest\externTest\write.h"
//////////////////
// Global variables
/////////////////
int Count = 5;
/////////////////
// Extern functions
/////////////////
extern void write_extern ();
int main()
{
int count = Count;
write_extern();
getchar ();
return 0;
}
write.h
#ifndef WRITE_H
#define WRITE_H
////////////////////////
// Includes
////////////////////////
#include "stdafx.h"
#include <iostream>
using namespace std;
////////////////////////
// Variables
////////////////////////
extern int count;
////////////////////////
// Function prototype
////////////////////////
void write_extern (void);
///////////////////////
#endif // !WRITE_H
write.cpp
// write.ccp
//////////////////
// Includes
/////////////////
#include <...\externTest\externTest\write.h>
////////////////////
// Functions definition
////////////////////
void write_extern ()
{
cout<< "Count is: \t" << count;
}
最後に、次のエラーが発生します。これは、パスが正しく定義されている場合でも、基本的にwrite.hファイルを認識しません。
falouji \ document \ visual studio 2012 \ projects \ externtest \ externtest \ write.cpp(5):警告C4627:'#include <... \ externTest \ externTest \ write.h>':プリコンパイル済みヘッダーの使用を探すときにスキップ1 >'stdafx.h'にディレクティブを追加するか、プリコンパイル済みヘッダーを再構築します
最後にあなたの助けを事前に感謝します:)