想象一下以下源文件:
src/StdAfx.h
src/moresrc/MyFile.cpp
Run Code Online (Sandbox Code Playgroud)
在MyFile.cpp,我需要包含预编译的头文件StdAfx.h.
如果我这样做:
#include "../StdAfx.h"
Run Code Online (Sandbox Code Playgroud)
然后我会得到编译器错误:
warning C4627: '#include "../stdafx.h"': skipped when looking for precompiled header use
fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
Run Code Online (Sandbox Code Playgroud)
所以这不起作用.如果我这样做的话
#include "StdAfx.h"
Run Code Online (Sandbox Code Playgroud)
然后编译正确,但我得到Visual Studio 2013中突出显示的恼人错误,如下所示:

所以,就像我说的,这个编译,但它很烦人.
如何在没有下划线的情况下包含"StdAfx.h",但是它会编译?
我现在正在尝试部署我的应用程序,它使用 Boost Log (Boost 1.58)。它是一个简单的控制台应用程序,在 Windows 7 中运行。日志记录在我的个人桌面上运行得非常好。
但是,当我将应用程序部署到 Win7 虚拟机时,它在我的第一个日志语句处崩溃:
boost::log::sources::severity_logger<SeverityLevel> slg;
BOOST_LOG_SEV(slg, SeverityLevel::Notification) << L"Application loaded"; // <-- Crash here
Run Code Online (Sandbox Code Playgroud)
日志目录已创建,但日志文件从未创建,并且应用程序崩溃。
我已经在我的 %APPDATA% 目录和我的文档目录中尝试了日志文件目录。
奇怪的是:当我以管理员身份运行该应用程序时,它可以工作!
所以这一定是一个权限问题,但我有这些文件夹的权限,所以......
有任何想法吗?
* 更多的 *
这是设置我的记录器的代码:
wstring appData = GetMyAppDataPath();
boost::shared_ptr< boost::log::sinks::synchronous_sink< boost::log::sinks::text_file_backend > > textFileSink(new boost::log::sinks::synchronous_sink< boost::log::sinks::text_file_backend >(to store rotated files
boost::log::keywords::file_name = "log_%7N.log", // file name pattern
boost::log::keywords::rotation_size = 16384 // rotation size, in characters
));
// Set up where the rotated files will be stored
textFileSink->locked_backend()->set_file_collector(boost::log::sinks::file::make_collector( …Run Code Online (Sandbox Code Playgroud) 在我的 C++ 代码中,我的#include语句混合使用了反斜杠和正斜杠。我想标准化使用正斜杠。
请记住,包含的内容可能如下所示:
#include "file.h"
#include <file.h>
#include "dir\file.h"
#include <dir\file.h>
#include <dir1\dir2\file.h>
#include "..\file.h"
Run Code Online (Sandbox Code Playgroud)
等等。
有谁知道使用 Visual Studio 2013 的“查找和替换”正则表达式功能来执行此操作的好方法?