compiler-warnings

Xcode -dynamic not specified static library error

淺唱寂寞╮ 提交于 2019-11-29 13:49:56
问题 I have a sub project within Xcode which creates a static library referenced by the parent project. All has been well until the release of iOS 7.1 and Xcode 5.1, suddenly I'm getting the following warning. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: -dynamic not specified the following flags are invalid: -ObjC warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Applications/Xcode.app

Why >>24 causes -Wconversion but >>23 doesn't?

早过忘川 提交于 2019-11-29 13:38:37
Here is the code: #include <stdint.h> unsigned char f(uint32_t RGBA) { return (RGBA>>24) & 0xFF; } When compiled with -Wconversion it causes "warning: conversion to ‘unsigned char’ from ‘uint32_t {aka unsigned int}’ may alter its value [-Wconversion]". If I lower the shift value to 23 or less the warning disappears. I've looked through the C99 standard and I don't understand what happens here. If I remove the & operator then the warning is always emitted and that is probably good, as the result of the expression (after integer promotions) is larger than unsigned char . My only idea is that the

Returning reference to a local variable

让人想犯罪 __ 提交于 2019-11-29 11:56:57
Why can this code run successfully in Code::block. The IDB just reports warning: "reference to local variable ‘tmp’ returned", but ouput the result "hello world" successfully. #include <iostream> #include<string> using namespace std; const string &getString(const string &s) { string tmp = s; return tmp; } int main() { string a; cout<<getString("hello world")<<endl; return 0; } prvit Maybe this link will help you. Upon leaving a function, all local variables are destroyed. By returning a reference to tmp , you are returning a reference to an object that soon ceases to exist (that is,

Why this “Implicit declaration of function 'X'”? [duplicate]

丶灬走出姿态 提交于 2019-11-29 11:26:23
问题 This question already has an answer here: warning: implicit declaration of function 6 answers I wrote a simple program to find the Sum, average, biggest and smallest number of 3 numbers. It lets the user to input three (integer) numbers and return the sum, average, max and min. It has no errors but a warning. Here is my source code: main.c: #include <stdio.h> int main() { int num1, num2, num3, sum, max, min, avg; printf("Enter Three \"Integer\" Numbers:"); scanf("%i%i%i", &num1, &num2, &num3)

Compiler warning: lambda return type cannot be deduced

淺唱寂寞╮ 提交于 2019-11-29 11:20:37
Consider this example: #include <algorithm> #include <iostream> int main() { std::string str = "abcde4fghijk4l5mnopqrs6t8uvwxyz"; std::string str2; std::remove_copy_if(str.begin(), str.end(), std::back_inserter(str2), [](char& c) { if (std::isdigit(c)) return true; // <----- warning here else return false; } ); std::cout << str2 << '\n'; } With GCC 4.6.1, this compiles fine and prints expected output (the alphabet) but I get a warning saying "lambda return type can only be deduced when the return statement is the only statement in the function body" . Now, I know how to get rid of the warning

Save and reprint warnings for successfully-compiled files on subsequent builds?

杀马特。学长 韩版系。学妹 提交于 2019-11-29 11:13:30
When repeatedly building a project, when there are warnings but no errors in a translation unit, the main source file is typically not recompiled. This can make it difficult to work through errors and warnings to attempt to get the project to build with no warnings. Typically one must keep iteratively building until all errors are taken care of, then do a full clean and build to ensure that there are no warnings (as well as to ensure that the previously-completed build wasn't a "fluke" caused by leftover build artifacts). Is there any way with CMake (or some other utility such as a Bash script

Avoid warning in wrapper around printf

余生颓废 提交于 2019-11-29 10:46:34
I have an error reporting functionality in my little C library I'm writing. I want to provide an errorf function in addition to the plain error function to allow embedding information in error messages easily. /* * Prints a formatted error message. Use it as you would use 'printf'. See the * 'sio_error' function. */ void sio_errorf(const char *format, ...) { // Print the error prefix if (g_input == STDIN) fputs("error: ", stderr); else fprintf(stderr, "%s: ", g_progname); // Pass on the varargs on to 'vfprintf'. va_list arglist; va_start(arglist, format); // This may produce the following

Multiple methods named “count” found with mismatched result, parameter type or attributes

大兔子大兔子 提交于 2019-11-29 10:04:42
Since the update to Xcode 5.1 I can't archive my project any more. Xcode always says "Multiple methods named "count" found with mismatched result, parameter type or attributes. This problem is new and simulator and running on device works fine. Here is the code: for ( int i = 0; i<[parseJSONArray count];i++){ for (int j = 0; j<[JSON[@"data"][@"menu"][i][@"item"] count];j++){ [pictureURL addObject:JSON[@"data"][@"menu"][i][@"item"][j][@"image"]]; } } Xcode shows the error at this point : [JSON[@"data"][@"menu"][i][@"item"] count] JSON is a NSDictionary . Whats wrong with this? Ask yourself:

disable warning c4702 seems not work for VS 2012

若如初见. 提交于 2019-11-29 09:28:10
I have some code for testing that i added upfront the rest of the code, so the rest would never be reached in the test. Since i have warning level 4 set, this results in an c4702: unreachable-code warning I tried disabling like this: //do something return 0; /*-------------------------------------------------------------------------*/ #pragma warning(disable: 4702) //real code but the compiler still moans. And because i have set to treat every warning as an error, this won't compile... I am using Visual Studio 2012 Premium... Any help would be gladly appreciated. You maybe just need to place

Suppress “discarded non-Unit value” warning

佐手、 提交于 2019-11-29 09:03:09
I have added the scalac command line argument -Ywarn-value-discard to my build because this would have caught a subtle bug that I just found in my code. However, I now get some warnings for "discarded non-Unit value" that are about intentional discards, not bugs. How do I suppress those warnings? You suppress these warning by explictly returning unit (that is () ). By example turn this: def method1() = { println("Hello") "Bye" } def method2() { method1() // Returns "Bye", whihc is implicitly discarded } into: def method1() = { println("Hello") "Bye" } def method2() { method1() () // Explicitly