gcc-warning

-fPIC ignored for target (all code is position independent), useless warning

半世苍凉 提交于 2019-12-10 01:17:55
问题 When I compile my library I have switched ont -fPIC because I want to be able to compile it as a shared library but also as static. Using gcc 3.4.4 on cygwin I get this warning on all source files: -fPIC ignored for target (all code is position independent) And I really wonder what's the point of it. It tells me that I use a switch which has no effect because what the switch should avieche is already accomplished. Well, it means it's redundant, fine. But what's the point of it and how can I

Have compiler check the number of array initializers

南笙酒味 提交于 2019-12-09 14:20:06
问题 Initializing an array (in C++, but any solution which works for C will likely work here as well) with less initializers than it has elements is perfectly legal: int array[10] = { 1, 2, 3 }; However, this can be a source of obscure bugs. Is there a way to have the compiler (gcc) check the number of initializers for one specific array, and emit a warning or even an error if declared and actual size don't match? I know I can use int array[] = { 1, 2, 3 }; and could then use static assertions

What causes compiler to warn for unused functions?

China☆狼群 提交于 2019-12-09 14:14:42
问题 Simple setup: There are n prototypes for functions and implementations of the functions. There is one big array of function pointers. Each function is listed in this array. Some still cause -Wunused-function when compiling with gcc. Code: void foo1(void); void foo2(void); void bar1(void); void bar2(void); /* and their implementations */ void (*functions[])(void) = { foo1, foo2, bar1, bar2 }; This is what the setup looks like (just an example)! One of this foo/bar functions now causes a

Warnings from boost

≡放荡痞女 提交于 2019-12-08 08:03:32
问题 I have lots of warning from boost library headers, is there any way to resolve this problem? libs/boost/include/boost/numeric/ublas/detail/vector_assign.hpp:382:39: warning: typedef ‘reference’ locally defined but not used [-Wunused-local-typedefs] typedef typename V::reference reference; libs/boost/include/boost/numeric/ublas/detail/vector_assign.hpp:516:40: warning: typedef ‘value_type’ locally defined but not used [-Wunused-local-typedefs] typedef typename V::value_type value_type; libs

Problem with installing Charm-Crypto for Python3

◇◆丶佛笑我妖孽 提交于 2019-12-08 05:02:56
问题 Hello fellow Programmers, currently I am trying to install Charm-Crypto 0.43 on my Ubuntu. Unfortunately nothing seems to work. I tried the linked manual install, as well as pip install charm-crypto I always get this Error log: [...] running build_ext building 'charm.core.math.pairing' extension creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/charm creating build/temp.linux-x86_64-3.6/charm/core creating build/temp.linux-x86_64-3.6/charm/core/math creating build/temp

Strict aliasing warning, creating uint32_t reference to unsigned char array + offset

徘徊边缘 提交于 2019-12-07 17:45:20
问题 With GNU GCC 4.7.0+ I got a few strict aliasing warnings, which I would like to resolve. I have a payload (from hardware): unsigned char payload[davidlt::PAYLOAD_SIZE]; I had this line: *(uint32_t*)(payload + davidlt::DATA_OFFSET) = (pid & davidlt::PID_MASK) << davidlt::PID_SHIFT; This creates a pointer to a specific location in payload and 4 bytes are interpreted as uint32_t . A new value uint32_t type is calculated and replaced in the payload. I get: warning: dereferencing type-punned

Remove first char of string C

孤街浪徒 提交于 2019-12-07 10:46:41
问题 Im trying to remove the first char of the string and keep the remainder, my current code doesnt compile and im confused on how to fix it. My code: char * newStr (char * charBuffer) { int len = strlen(charBuffer); int i = 1; char v; if(charBuffer[0] == 'A' || charBuffer[0] == 'Q'){ for(i=1;i<len;i++) v = v + charBuffer[i]; } v = v + '\0'; return v; } Gcc: "Warning: return makes pointer from integer without a cast" Also: "char * newStr (char * charBuffer)" needs to remain the same. 回答1: Strings

Wunused-but-set-variable warning treatment

混江龙づ霸主 提交于 2019-12-07 04:58:55
问题 I have the following code, and while compiling it with gcc-4.6 I get warning: warning: variable ‘status’ set but not used [-Wunused-but-set-variable] #if defined (_DEBUG_) #define ASSERT assert #else /* _DEBUG_ */ #define ASSERT( __exp__ ) #endif static inline void cl_plock(cl_plock_t * const p_lock) { status_t status; ASSERT(p_lock); ASSERT(p_lock->state == INITIALIZED); status = pthread_rwlock_unlock(&p_lock->lock); ASSERT(status == 0); } When _DEBUG_ flag isn't set I get the warning. Any

Disable gcc warning for incompatible options

随声附和 提交于 2019-12-07 04:27:53
问题 I'm curious if there is an option to disable gcc warnings about a parameter not being valid for the language being compiled. Ex: cc1: warning: command line option "-Wno-deprecated" is valid for C++/Java/ObjC++ but not for C Our build system passes the warnings we have decided on globally across a build. We have both C/C++ code and the warnings get real annoying when trying to find actual warnings. Any suggestions? 回答1: It seems to me that if there were such an option, there would have to be a

Why assignment of double to int does not trigger gcc warnings?

穿精又带淫゛_ 提交于 2019-12-07 03:35:54
问题 int i = 3.1 / 2 does not cause any warnings,even with -Wall option.Sometimes,I would like to know where precision lose.Why gcc does not support this warning,while msvc support this one? thanks. EDIT: my gcc -v shows Configured with: ../../gcc-4.4.1/configure --prefix=/mingw --build=mingw32 --enable-languages=c,ada,c++,fortran,objc,obj-c++ --disable-nls --disable-win32-registry --enable-libgomp --enable-cxx-flags='-fno-function-sections -fno-data-sections' --disable-werror --enable-threads -