草庐IT

getopt_long_only

全部标签

c++ - make_signed<unsigned long>::type 是 int?

我使用的是VisualStudio2010,下面的代码让我有些困惑:#includeautox=std::make_signed::type();x将是int类型,但我预计会很长。我知道VS10中的int和long都是4字节整数。但是即使一个signedlong装进一个int,int对我来说也不是unsignedlong对应的signedinteger类型。所以我的问题是:这是错误/技术错误还是标准规范允许这种结果? 最佳答案 C++1120.9.7.3[meta.trans.sign]描述了make_signed:IfTnames

C++ signed 和 unsigned int 与 long long 速度

今天,我注意到几个简单的按位和算术运算的速度在int之间有显着差异。,unsigned,longlong和unsignedlonglong在我的64位电脑上。特别是,对于unsigned,以下循环的速度大约是其两倍至于longlong,这是我没想到的。intk=15;intN=30;intmask=(1(完整代码here)以下是计时(以秒为单位)(对于g++-O、-O2和-O3):1.834207723(int)3.054731598(longlong)1.584846237(unsigned)2.201142018(unsignedlonglong)这些时间非常一致(即1%的差值)。

c++ - Visual Studio 错误 : LNK1104: cannot open file 'kernel32.lib' - only in WP8 projects/Win32 builds

我最近遇到了这个问题(几天前一切正常):VisualStudio2012开始拒绝构建原生WP8项目。今天,我从模板“WindowsPhoneDirect3D应用程序(仅限native)”创建了新解决方案,以检查WP是否正确支持我新创建的DLL。我尝试编译这个项目,首先没有任何更改或额外的引用-VS生成的纯代码。但是,它因给定错误而失败。我很清楚这是什么意思,可能的原因是什么,但是我不明白,在这种情况下它是从哪里来的。奇怪的事情:这只发生在“Win32”配置中,ARM编译正常:1>------Buildstarted:Project:PhoneDirect3DApp,Configurat

Ubuntu扩容报错:Unable to resize read-only file system /dev/sda3

当我们给Ubuntu新划分了空间,但是去给磁盘划分的时候,会报错:Unable to resize read-only file system /dev[sda3The file system can not be resized while it is mounted read-only.Either unmount the file system or remount it read-write.这是因为磁盘没有挂载起来,因此需要查看该磁盘的挂载路径,首先右键/dev/sda3点击信息,进去后就可以看到挂载的路径,分别是/和/var/snap/firefox/common/host-hun

c++ - 解决 "only static const integral data members can be initialized within a class"编译错误

以下创建全局对象会导致编译错误。#include"stdafx.h"#includeusingnamespaceSystem;usingnamespacestd;#pragmahdrstopclassTester;voidinput();classTester{staticintnumber=5;public:Tester(){};~Tester(){};voidsetNumber(intnewNumber){number=newNumber;}intgetNumber(){returnnumber;}}TestertesterObject;voidmain(void){cout>ne

c++ - QSocketNotifier : Can only be used with threads started with QThread error

我正在尝试使用QLocalServer作为ipc解决方案。qt的版本是4.6这是我的main.cpp:intmain(intargc,constchar*argv[]){QServertest();while(true){}}这是我的QServer类:classQServer:publicQObject{Q_OBJECTpublic:QServer();virtual~QServer();private:QLocalServer*m_server;QLocalSocket*m_connection;privateslots:voidsocket_new_connection();};Q

c++ - std::streampos 是否保证为 unsigned long long?

std::streampos是否保证为unsignedlonglong?如果不是这样,std::istream::seekg如何在大于4G的文件上正常工作? 最佳答案 来自http://en.cppreference.com/w/cpp/io/fpos:std::streampos是类模板的特化templateclassfpos;std::streampos类型定义为std::fpos::state_type>类型为fpos的每个对象保存流中的字节位置(通常作为std::streamoff类型的私有(private)成员)。来自ht

c++ - gcc编译C++代码: undefined reference to `operator new[](unsigned long long)'

有一段C++代码:#includeintmain(){intb=sizeof('a');if(b==4)printf("I'maCprogram!\n");elseprintf("I'maC++program!\n");}像这样编译:gccmain.cpp-omain它成功并给出:I'maC++program!然后在函数main的某处添加一行int*p1=newint[1000];它失败了:C:\Users\...\AppData\Local\Temp\cccJZ8kN.o:main1.cpp:(.text+0x1f):undefinedreferencetooperatornew[]

c++ - (signed) long long 的真正下限是多少?

使用longlong检查类型的限制std::cout::min();我得到-9223372036854775808但是在编译以下代码时:intmain(){longlongl;l=-9223372036854775808LL;}我收到警告:test.cpp:3:7:warning:integerconstantissolargethatitisunsigned.test.cpp:3:warning:thisdecimalconstantisunsignedonlyinISOC90我错过了什么?非常感谢您的帮助。乔治 最佳答案 这个9

C++ double 到 long long

如果我用c++写代码:longlongd=999999998.9999999994;cout我得到输出:999999999(四舍五入)但是这段代码的输出:longlongd=999999998.9999994994;cout是999999998(向下舍入)跟精度有关系吗?有什么办法可以改变精度。floor()函数也给出相同的输出。我还注意到,如果我将值8.9999994994或8.9999999994分配给d(上述变量)。输出为8。 最佳答案 999999998.9999999994不能用double精确表示,因此实际值是99999