草庐IT

redef_without_warning

全部标签

c++ - 在 constexpr 函数中返回一个 C 字符串 : why no warning from the compiler?

考虑以下代码:constexprautof(){autostr="HelloWorld!";returnstr;}intmain(intargc,char*argv[]){staticconstexprautostr=f();std::cout我的编译器不显示任何警告是否正常?它是定义的行为吗?我能保证程序会显示"HelloWorld!"吗?我希望"HelloWorld!"不会超出函数的范围... 最佳答案 在C++中stringliterals有staticstorageduration只要程序运行就可以生存。因此,指向从f返回的

c++ - 关于 "warning C4312: ' 类型转换的问题'”

这是我的代码:HWNDWebformCreate(HWNDhParent,UINTid){returnCreateWindowEx(0,WEBFORM_CLASS,_T("about:blank"),WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,100,100,hParent,(HMENU)id,GetModuleHandle(NULL),0);}这是我收到的警告:warningC4312:'typecast':conversionfrom'UINT'to'HMENU'ofgreatersize这些是我的问题:为什么编译器认为转换为更大的类型是个坏主意

c++ - 我可以从 "treat warnings as errors"中排除一些特定的警告而不禁用它们吗?

在我的VisualC++代码中,我想要/WX-“将警告视为错误”。这让我处理每个警告,包括C4996-“Xwasdeclareddeprecated”我不想解决-我现在不想更改代码,我不想禁用C4996以便它保留在输出中。所以理想情况下我想要这样的东西:#pragmawarning(ExcludeFromWX:4996)因此,当使用/WX时,除此之外的所有警告都被视为错误,并且仅显示此警告并继续编译。是否有可能得到这样的行为? 最佳答案 您可以使用以下pragma重置指定的警告。我没有测试过,你也没有提到尝试这个:更新更改警告级别应

c++ - qmake : Build library without the symlinks and 'lib' prefix

我在我的应用程序中需要一个非常简单的机制,我的项目构建为共享库“.so”或“.dll”,但我想要的是:ExampleAppOne.so我得到:libExampleAppOne.so->libExampleAppOne.so.1.0.0libExampleAppOne.so.1->libExampleAppOne.so.1.0.0libExampleAppOne.so.1.0->libExampleAppOne.so.1.0.0我什至不想要“lib”前缀。在.pro文件中,我所能做的就是更改INSTALLS变量(这是因为我的第三个要求是将库构建在特定目录中)。此外,我还有第四个相关要求:

c++ - #pragma warning 不抑制警告

我的一个.cpp文件由于第3方header生成警告C4275#include...(由于DLL导出类继承自非据我所知,DLL导出类)。我添加了一行:#pragmawarning(disable:4275)作为我的.cpp文件的第一行,但警告仍在生成。这是在VC++2008上,没有使用PCH。为什么我的#pragma不起作用,并且(除了更改第3方代码之外)我该如何解决这个问题? 最佳答案 生成一个预处理文件,您可能会发现其他一些头文件重新启用警告。 关于c++-#pragmawarning

c++ - 为什么在mac中禁止使用fork without exec?

我的问题很简单。在Linux上,使用不带exec的fork非常流行但是,我发现在MacOS上这是不可能的(参见fork手册)https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/fork.2.htmlTherearelimitstowhatyoucandointhechildprocess.Tobetotallysafeyoushouldrestrictyour-selfyourselfselftoonlyexecutingasync-signalsafeoperatio

c++ - Lambda 捕获列表 : capturing object's member field by value not possible without capturing the whole object?

下面的代码voidCMainWindow::someMethod(constCLocationsCollection&parentItem){autof=[this,parentItem.displayName](){};}给我一​​个错误:errorC2143:syntaxerror:missing']'before'.'如果我想通过ref捕获parentItem.displayName,我会为它创建一个非依赖别名标识符:constQString&name=parentItem.displayName;autof=[this,&name](){};//Orshoulditbe[thi

【已解决】redis启动错误: Warning: no config file specified, using the default config. In order to specify a

Warning:noconfigfilespecified,usingthedefaultconfig.Inordertospecifyaconfigredis启动报如下错误:意思是:启动时无法找到配置文件,远程无法连接解决方法:第一种:在cmd命令行中执行redis-server.exeredis.windows.conf第二种:在redis的根目录下新建一个start.bat文件,将redis-server.exeredis.windows.conf放在文件里,双击start.bat即可启动。也可以解决上述问题下面说说一个小问题:如何更改密码?首先如果是想一劳永逸,那么在redis.win

android - Kotlin + Dagger2 : cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method

我收到以下错误:Error:(8,1)error:java.lang.Stringcannotbeprovidedwithoutan@Injectconstructororfroman@Provides-or@Produces-annotatedmethod.我一直在尝试制作一个提供两个合格字符串的模块。这是Dagger的简化设置。@Singleton@Component(modules=[GreetingsModule::class])interfaceAppComponent{funinject(activity:MainActivity)}@Qualifierannotation

android - Kotlin + Dagger2 : cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method

我收到以下错误:Error:(8,1)error:java.lang.Stringcannotbeprovidedwithoutan@Injectconstructororfroman@Provides-or@Produces-annotatedmethod.我一直在尝试制作一个提供两个合格字符串的模块。这是Dagger的简化设置。@Singleton@Component(modules=[GreetingsModule::class])interfaceAppComponent{funinject(activity:MainActivity)}@Qualifierannotation