gcc-warning

expected expected ‘const char **’ but argument is of type ‘char **’

夙愿已清 提交于 2020-11-27 19:42:52
问题 Here is the compile warning i have: src/Debugger.c:219:52: warning: passing argument 2 of ‘Debugger_Command[i].Callback’ from incompatible pointer type Debugger_Command[i].Callback(argc, argv); ^ src/Debugger.c:219:52: note: expected ‘const char **’ but argument is of type ‘char **’ Here is the relevant source code: /* Definition */ typedef void (*Debugger_Callback_t)(int argc, char const * argv[]); typedef struct tagDebugger_Command_t { /* ... */ Debugger_Callback_t Callback; /**< Callback *

expected expected ‘const char **’ but argument is of type ‘char **’

喜欢而已 提交于 2020-11-27 19:42:44
问题 Here is the compile warning i have: src/Debugger.c:219:52: warning: passing argument 2 of ‘Debugger_Command[i].Callback’ from incompatible pointer type Debugger_Command[i].Callback(argc, argv); ^ src/Debugger.c:219:52: note: expected ‘const char **’ but argument is of type ‘char **’ Here is the relevant source code: /* Definition */ typedef void (*Debugger_Callback_t)(int argc, char const * argv[]); typedef struct tagDebugger_Command_t { /* ... */ Debugger_Callback_t Callback; /**< Callback *

expected expected ‘const char **’ but argument is of type ‘char **’

我是研究僧i 提交于 2020-11-27 19:42:22
问题 Here is the compile warning i have: src/Debugger.c:219:52: warning: passing argument 2 of ‘Debugger_Command[i].Callback’ from incompatible pointer type Debugger_Command[i].Callback(argc, argv); ^ src/Debugger.c:219:52: note: expected ‘const char **’ but argument is of type ‘char **’ Here is the relevant source code: /* Definition */ typedef void (*Debugger_Callback_t)(int argc, char const * argv[]); typedef struct tagDebugger_Command_t { /* ... */ Debugger_Callback_t Callback; /**< Callback *

GCC : Static array index in function argument doesn't trigger any warning

ぐ巨炮叔叔 提交于 2020-05-23 09:19:50
问题 I'm trying to understand the use of the "static" keyword as an array index in a function declaration in C. After reading this article, I tried to declare such a function, and purposefully passing it an array that is too short: #include <stdio.h> #include <stdlib.h> void print_string10(char string10[static 10]) { // Should trigger a warning if the argument is NULL or an array of less than 10 elements printf("%s\n",string10); } int main(void) { char short_string[] = "test"; print_string10(short

Error : format'%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat=]

那年仲夏 提交于 2020-04-07 06:46:30
问题 I am currently trying to do my own shell, and it has to be polyglot. So I tryed to implement a function that reads the lines in a .txt file. #include <stdio.h> #include <stdlib.h> #include <string.h> // globals char lang[16] = {'t','r','y'}; char aMsg[512]; // functions void takeFile() { int i =0; char namFil[32]; char lg[16]; FILE * file; char tmp[255]; char * line = tmp; size_t len = 0; ssize_t read; strcpy(namFil,"/media/sf_Projet_C/"); strcpy(lg,lang); strcat(lg, ".txt"); strcat(namFil,

GCC Compiler options -wno-four-char-constants and -wno-multichar

試著忘記壹切 提交于 2020-01-23 11:48:08
问题 Couldn't find any documentation on -Wno-four-char-constants , however I suspect that it is similar to -Wno-multichar . Am I correct? 回答1: They're related but not the same thing. Compiling with the -Wall --pedantic flags, the assignment: int i = 'abc'; produces: warning: multi-character character constant [-Wmultichar] with both GCC and CLANG, while: int i = 'abcd'; produces: GCC warning: multi-character character constant [-Wmultichar] CLANG warning: multi-character character constant [-Wfour

How to let GCC warn unmatched number of arguments when making function calls?

风格不统一 提交于 2020-01-16 01:14:07
问题 I just debugged a C program for a long time, only to find that I missed an argument when making a function call, so junk instead filled the missing argument. Stupid mistakes like this are really frustrating, but I suppose compilers should be able to detect this. (C doesn't even support default arguments; even in C++, default arguments need to be explicitly declared.) Update: The prototype was found to be wrong, too... So, is there a GCC flag for warning unmatched function call argument number

hidden symbol `stat' in libc_nonshared.a(stat.oS) is referenced by DSO

試著忘記壹切 提交于 2020-01-06 17:55:39
问题 I'm trying to use methods contained in a shared library ( libscplugin.so ). I have satisfied all of the libraries requirements: libc.so with a symlink to libc.so.6 libz.so with a symlink to libz.so.1.2.8 libstdc++.so with a symlink to libstdc++.so.6.0.20 Upon compilation I get the following error message: $ gcc test.c -o test -L/usr/lib/arm-linux-gnueabihf/ -lscplugin /usr/bin/ld: test: hidden symbol `stat' in /usr/lib/arm-linux-gnueabihf/libc_nonshared.a(stat.oS) is referenced by DSO /usr

GCC -Wuninitialized not warning about uninitialized structs

守給你的承諾、 提交于 2020-01-06 02:14:17
问题 #include <ctime> #include <iostream> #include <cstring> int main() { struct tm tm ; //memset(&tm, 0, sizeof(struct tm)); strptime("1 Jan 2000 13:00:00", "%d %b %Y %H:%M:%S", &tm); time_t t =mktime(&tm); std::cout << ctime(&t); return 0; } g++ -Wuninitialized -O2 test.cpp doesn't warn about tm not having been initialized. Valgrind does until the memset line is added. the Man pages for strptime on Linux say it should be initialised and I was seeing randomized dates on a more complicated program