有没有办法通过编译指示添加源文件?

发布于 2024-12-03 15:01:55 字数 90 浏览 1 评论 0原文

有没有办法通过 pragma 指令将源文件添加到要在 Visual Studio 10 中编译的文件列表中?这样,无论何时包含头文件,都可以将其实现文件一起包含在内。

Is there any way, via a pragma directive, to add a source file to the list of files to be compiled in Visual Studio 10? That way header files could bring their implementation files along with them whenever they are included.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一个人的夜不怕黑 2024-12-10 15:01:55

据我所知没有这样的事情。如果支持类似的东西,那么跟踪项目依赖关系将会变得非常复杂。

但图书馆也有类似的东西。假设您有一个名为library.lib 的库和一个声明该库的符号的头文件(名为library.h)。您可以在library.h中包含以下编译指示:

#pragma comment(lib, "library.lib")

然后任何包含library.h的项目都会自动链接到library.lib。

此选项在此页面上进行了描述MSDN。

As far as I know there is no such thing. It would make it awfully complicated to keep track of project dependencies if something like that was supported.

But there is something like that for libraries. Say you have a library called library.lib and a header file that declares the symbols for this library called library.h. You can include the following pragma in library.h:

#pragma comment(lib, "library.lib")

And then any project that includes library.h will link against library.lib automatically.

This option is described on this page on MSDN.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文