草庐IT

internal-storage

全部标签

c++ - "internal linkage"是什么意思?

在标准中它说:Whenanamehasinternallinkage,theentityitdenotescanbereferredtobynamesfromotherscopesinthesametranslationunit.和:Anamehavingnamespacescope(3.3.6)hasinternallinkageifitisthenameof—avariable,functionorfunctiontemplatethatisexplicitlydeclaredstatic;因此请考虑以下代码:#includenamespaceA{/*awithinternalli

c++ - Windows::Storage::ApplicationData::Current 在 C++ 中找不到

我的C++代码,属于MediaFoundationTransform的一部分倾向于能够在WindowsStoreApp(Metro)中运行我修改了C++GrayscaleTransform以包含以下代码。但是,我的C++代码无法找到命名空间Windows::Storage。LPCWSTRzPath=Windows::Storage::ApplicationData::Current->TemporaryFolder->Path->Data();我需要做任何额外的设置吗?我可以通过打开使用Windows运行时扩展来编译它。但是通过这样做,它会给我额外的链接错误和警告。warningLNK

c++ - 分配器 : how are the standard containers expected to work internally?

作为这个问题的示例,我将使用std::vector。它的定义来自documentation如下:template>class vector;正如预期的那样,如果T是它的类型,分配器应该偏向于T。总之,下面的代码编译没有错误(至少,使用GCC)并运行:#include#include#includestructS{inti;doubled;std::strings;};intmain(){std::allocatoralloc;std::vector>v{alloc};v.push_back(S{});}在这里,我通过使用专注于int的分配器创建vector的S。它是合法的代码吗?我应该

c++ - 具有负大小的 Google Mock testing::internal::ReturnAction<R> 数组

我有测试代码可以做类似的事情EXPECT_CALL(mock,getSomeString()).WillOnce(Return(&testString));其中getSomeString()通过引用返回:std:string&getSomeString();得到../../../../src/test/unit/gmock/gmock-actions.h:Inmemberfunction‘testing::internal::ReturnAction::operatortesting::Action()const[withF=conststd::string&(),R=std::bas

c++ - GCC 7,aligned_storage 和 "dereferencing type-punned pointer will break strict-aliasing rules"

我编写的代码在GCC4.9、GCC5和GCC6中没有警告。它在一些较旧的GCC7实验快照(例如7-20170409)中也没有警告。但在最近的快照(包括第一个RC)中,它开始产生关于别名的警告。代码基本上可以归结为:#includestd::aligned_storage::typestorage;intmain(){*reinterpret_cast(&storage)=42;}使用最新的GCC7RC编译:$g++-Wall-O2-cmain.cppmain.cpp:Infunction'intmain()':main.cpp:7:34:warning:dereferencingtyp

c++ - C++ 引用是否保证使用指针 "internally"?

查看C++中的引用,我注意到我查看的所有实现都在内部使用了一个指针。C++标准是否保证引用将在内部使用指针,或者实现是否可以使用更“高效”的解决方案?(我目前看不出如何“更好”地完成它,因为当创建一个新的堆栈框架时,并没有真正可靠的方法来轻松地知道被引用的变量与堆栈基指针的偏移量是多少,因为堆栈非常有活力)注意:我确实理解C++中指针和引用之间的区别(这个问题与此无关) 最佳答案 如果您的意思是引用需要编译器为指针分配存储空间,那么这是未指定的。§8.3.2/4Itisunspecifiedwhetherornotareferenc

C++ fatal error C1001 : An internal error has occurred in the compiler

在Release模式下编译时出现以下错误。1>d:\users\eyal\projects\code\yalla\core\src\runbox\win32\window.cpp:fatalerrorC1001:Aninternalerrorhasoccurredinthecompiler.1>(compilerfile'f:\dd\vctools\compiler\utc\src\p2\main.c',line249)1>Toworkaroundthisproblem,trysimplifyingorchangingtheprogramnearthelocationslistedab

c++ - mock_method 上的 gmock 编译错误(在 testing::internal::FunctionMocker 中)

当我尝试模拟一个函数时,我遇到了一些奇怪的编译错误。编译器提示复制构造函数有问题。代码片段:classdb_key{public:db_key(void){}explicitdb_key(constchar*buf){}~db_key(void){}};classbar_A{public:explicitbar_A(constdb_key&key):m_key(key){}virtual~bar_A(void){}constdb_key&dbkey(void)const{returnm_key;}private:constdb_keym_key;};classbar_B:bar_A{p

c++ - 如何填充sockaddr_storage?

我正在尝试在我的应用程序中使用sockaddr_storage结构。我很好奇如何填写它。例如我有以下代码:sHostAddr.sin_family=AF_INET;sHostAddr.sin_addr.s_addr=inet_addr(cpIPAddress);如果我使用sockaddr_storage结构,我该如何替换它?我知道有一些char数组,我想我可以使用一些数组索引偏移量获得等效代码?提前致谢。 最佳答案 名字就是提示,sockaddr_storage只是用来存储的,不是用来访问的。在具有特定协议(protocol)结构的

c++ - C1001 : An internal error has occurred in the compiler

这应该是不言自明的。我正在尝试实现分布排序,但MSVC编译器崩溃了。这似乎是用我的SFINAE检测成员函数的特定情况,如果我不将indexert传递给函数,或者替换has_get_index,这似乎不会发生。如果我删除剩余的索引器重载中的任何一个,它也不会发生。如果sortable有一个getIndex()const成员,问题仍然存在。1>test.cpp(34):fatalerrorC1001:Aninternalerrorhasoccurredinthecompiler.1>(compilerfile'msc1.cpp',line1420)1>Toworkaroundthispro