家伙,我试图在VS做这样的事情:如何检查是否MS编译器编译我的源代码
#ifdef _MSC_VER
#include "stdafx.h"
#endif
,但我得到一个错误,告诉我:
C1020: unexpected #endif
什么是做到这一点的正确方法?
编辑
/这是stdafx.h中的内容/
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
//#include <stdio.h>
//#include <tchar.h>
#include <iostream>
using std::cout;
using std::cerr;
// TODO: reference additional headers your program requires here
这是造成错误的确切代码段吗?你能显示“stdafx.h”的内容吗? –
和targetver.h中是什么?只要你的头文件是正确的,原始代码也是正确的。尝试删除文件中的#ifdef ... #endif。汇编应该失败,并给你真正的错误。 – PierreBdR
#PierreBdR好吧,我刚刚找到它。此代码编译,但在VS为了编译它必须关闭预编译头。不管怎么说,还是要谢谢你。 – smallB