gcc-warning

How to suppress GCC warnings from library headers?

妖精的绣舞 提交于 2019-12-17 02:09:26
问题 I have a project that uses log4cxx, boost, etc. libraries whose headers generate lots of (repetitive) warnings. Is there a way to suppress warnings from library includes (i.e. #include <some-header.h>) or includes from certain paths? I'd like to use -Wall and/or -Wextra as usual on project code without relevant info being obscured. I currently use grep on make output but I'd like something better. 回答1: You may try to include library headers using -isystem instead of -I . This will make them

g++ warning: comparison of unsigned expression < 0 is always false

别等时光非礼了梦想. 提交于 2019-12-14 01:50:41
问题 To compile my C++ code I use the -W flag, which causes the warning: warning: comparison of unsigned expression < 0 is always false I believe this was considered as a bug and was fixed on version GCC 4.3, but I'm using GCC 4.1 Code that is obviously offending here: void FieldGroup::generateCreateMessage (const ApiEvent::GroupData &data, omsgstream &result) const { dblog << debug; // Write out the data fields we care about, in the order they were specified for (size_t index = 0; index < fields

Signed / unsigned comparison and -Wall

杀马特。学长 韩版系。学妹 提交于 2019-12-12 19:23:03
问题 I have recently started using the -Wall compiler switch in an attempt to improve the quality of my code. It is giving (correctly) a warning about this little snippet... int i; for (i = start - 1; i >= 0; i--) { if (i >= number1.array.size()) { one_value = 0; } because number1.array.size is unsigned (it's the size method on a std::vector). Since the test in the loop is i >= 0, i has to be signed or it doesn't work. It seems I have three choices; to refrain from using -Wall, to ignore the

Why gcc does not produce type mismatch warning for int and char?

青春壹個敷衍的年華 提交于 2019-12-12 17:11:44
问题 Why compiling the following code in gcc does not produce any type mismatch warning? -1 is of type int , and f() expects type char : void f(char c) {} int main(void) { f(-1); return 0; } Even if we explicitly specify the types, there is no warning: void f(unsigned char c) {} int main(void) { f((signed int)-1); return 0; } What is curious: if we specify out-of-range value, the warning is printed: void f(char c) {} int main(void) { f(65535); return 0; } warning: overflow in implicit constant

Suppress GCC warning “extra tokens at end of #include directive”

主宰稳场 提交于 2019-12-12 15:44:43
问题 I'm writing a program in C intended to be compiled and run on a HP NonStop machine. However, I want to do the main development on my workstation running Linux. The HP NonStop C-Compiler requires non-standard #include directives like the following: #include <stdio.h> nolist For each #include directive, my workstation's GCC is complaining: S88USF.c:139:21: warning: extra tokens at end of #include directive How can I suppress this particular warning? Note: On SO, similar questions have already

How to get compiler warnings JUCE - Ubuntu [closed]

感情迁移 提交于 2019-12-12 06:46:22
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago . I was recently dealing with an error that should have easily been realized with a simple compiler warning. Does anyone know how to get compiler warnings to show up when compiling JUCE projects with make on Ubuntu? I attempted: make -Wall from the gcc/gnu Warning Options docs -> no change make V=1

Compiler Error in DEV-C++

对着背影说爱祢 提交于 2019-12-11 20:39:40
问题 I compiled the following code which is declared with #include <strsafe.h> in my C code and I am getting the following compiler errors in DEV-C++. I guess there should be some option in compiler to solve this. Can somebody help to solve this. The below is my sample code which is taken from MSDN site : #include <windows.h> #include <strsafe.h> void ErrorExit(LPTSTR lpszFunction) { // Retrieve the system error message for the last-error code LPVOID lpMsgBuf; LPVOID lpDisplayBuf; DWORD dw =

implicit declaration of function

早过忘川 提交于 2019-12-11 12:25:28
问题 GCC typically yields this warning when the proper header file is not included. This link --> www.network-theory.co.uk/docs/gccintro/gccintro_19.html says that because the function declaration is implicit (rather than explicitly declared via a header) the wrong argument types could actually be passed to the function, yielding incorrect results. I don't understand this. Does this mean the compiler generates code that pushes something, of the machine's word size, onto the stack for the callee to

gcc 4.9.2 bug in -Wmissing-field-initializers?

大憨熊 提交于 2019-12-11 10:43:49
问题 I have an issue in this code - which can be copied 1:1 into a cpp file in order to test the behaving: #include <atomic> typedef struct { char sDateTime [20]; char sLogFileDirectory [300]; char sLogFileNameTemplate [300]; char sLogOutput [10][100]; std::atomic<bool> bReadyToFlush; } LogEntries; typedef struct { LogEntries leLogEntries [1] {}; } LogThreads; Compiling with gcc 4.9.2 SLES 11 SP2 g++ -std=c++11 gcc-warning-bug.cpp -Wall -Wextra -c I receive these very strange warnings: gcc-warning

has no member compilation error

无人久伴 提交于 2019-12-11 07:32:31
问题 I have the following code and when I'm trying to compile it, I get an error: error: ‘list_item_t’ has no member named ‘state’ Any creative ideas how to make this piece of code compile without warnings and erros? #if defined (_DEBUG_) #define ASSERT assert #else /* _DEBUG_ */ #define ASSERT( exp ) ((void)(exp)) #endif` typedef struct list_item { struct list_item *p_next; struct list_item *p_prev; #ifdef _DEBUG_ int state; #endif } list_item_t; main(int argc, char *argv) { list_item_t p_list