Visual studio包含可见性

Visual studio include visibility

本文关键字:可见性 包含 studio Visual      更新时间:2023-10-16

我在visualstudio中遇到了includes的问题。我想为windows和linux编译这个项目。

在visualstudio中,我在.hpp文件中得到了一个小类,它使用了std::exceptionstd::is_pod<T>,但我没有包括type_traitsstdexcept!!该文件使用Visual Studio编译得很好!为什么?

在linux上这样做会给我错误

In file included from Packet.hpp:3:0,
                 from AbstractPacketFactory.hpp:2,
                 from AuthenticationPacketFactory.hpp:2,
                 from AuthenticationPacketFactory.cpp:1:
ByteSerializer.hpp: In member function ‘byte_serializer& byte_serializer::operator>>(T&)’:

linux g++是正确的-为什么visualstudio没有警告我?我能做点什么吗?我使用VS作为我的主要IDE,我希望在未来避免这种意外(目前有50个这样的错误…)

我得到了一个出错的函数:

static_assert(std::is_pod<T>, "T must be a POD");

您必须将它与::value()一起使用,但visualstudio编译std::is_pod<T>时没有任何警告。这就是错误雪崩的原因。。。

您的Visual Studio项目可能被配置为使用预编译头。当您使用预编译头时,stdafx.h就在那里。

只需从预编译头中删除stdafx.h,然后查看编译是否在windows上成功。

您可以在"项目属性">"C++">"预编译头"中找到预编译头。

如果要进行跨平台项目,则应删除"预编译"设置。