c,compilation,cuda,gcc-warning,nvcc
this link: https://devtalk.nvidia.com/default/topic/388072/calling-cuda-functions-from-a-c-file/ answers your question:,. basically: in the .c file #include <stdio.h> #include <stdlib.h> #include <string.h> #include <cuda.h> extern void kernel_wrapper(int *a, int *b); int main(int argc, char *argv[]) { int a = 2; int b = 3; kernel_wrapper(&a, &b); return 0; } and in the .cu file; __global__...
c++11,suppress-warnings,gcc-warning
Better to change the code to avoid this warning rather than suppressing it! If not handled correctly, it may cause runtime surprises which will be much harder to find. [Note: To answer your question, which should be taken with a grain of salt, you may use free() instead of delete,...
Your compiletime_assert framework is relying on the optimizer performing dead code elimination to remove the call to prefix ## suffix. This is highly fragile and is in no way guaranteed to work. Instead, try using one of the solutions from Ways to ASSERT expressions at build time in C -...
I found your problem! check that link: http://thecodecracker.com/c-programming/dining-philosophers-problem/comment-page-1/
From the Linux Programmer's Manual: WAIT(2) Linux Programmer's Manual WAIT(2) NAME wait, waitpid, waitid - wait for process to change state SYNOPSIS #include <sys/types.h> #include <sys/wait.h> pid_t wait(int *status); So add those two #includes to use wait()....
I managed to come up with a solution to my own problem: // Prototype void getneighbours (uint8_t (*nei)[2][4], uint8_t nodex, uint8_t nodey); // Call uint8_t neighbours[2][4]; getneighbours (&neighbours, nodex, nodey); So for people having the same issue, this would be how you properly handle multidimensional array pointers....
c,security,gcc,gtk,gcc-warning
The answer is quite simple. You have to add "%s" to the arguments of the gtk_message_dialog_new() function like this: static void show_message (gchar *message, GtkMessageType type) { GtkWidget *dialog = gtk_message_dialog_new(NULL, 0, type, GTK_BUTTONS_OK, "%s", message); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } Basically, the lack of "%s" is considered non-secure by gcc. You...
Use the -O (optimize) option; value tracking is only performed on optimized code. $ gcc -Wall -O x.c x.c: In function ‘main’: x.c:15: warning: ‘sum’ is used uninitialized in this function ...
gcc,compiler-construction,gcc-warning
Signed integer overflow (as strictly speaking, there is no such thing as "unsigned integer overflow") means undefined behaviour. Unsigned integers, declared unsigned, shall obey the laws of arithmetic modulo 2n where n is the number of bits in the value representation of that particular size of integer.I suspect that it's...
linux-kernel,filesystems,gcc-warning
Met the same error before. U should add <linux/aio.h> as ext2 uses asynchronous IO for reading/writing files. Hope that helps :)
c,binary-search-tree,scanf,gcc-warning
scanf("Enter the node value: %d", &val); should be scanf("%d", &val); and scanf("Want to enter more: %c", &ch); should be scanf(" %c", &ch); Assuming you are intending to this printf("Enter the node value:\n"); if(scanf("%d", &val) != 1) { printf("Integer not read \n"); break; } printf("Want to enter more:\n"); if(scanf(" %c", &ch)...
-Wtype-limits (or -Wextra) should trigger this warning
Because technically you may be breaking a promise by passing a non-const pointer into a const pointer parameter. "It is dangerous to take away const-ness" http://c-faq.com/ansi/constmismatch.html ...
Certainly the gcc compiler warnings already name the involved type(s). Possibly you mean something like that: int func() { static int i; return i++; } What's the return value restricted to as a type? ISO/IEC 9899:201x, 6.9.1 Function definitions, Constraints 3 The return type of a function shall be...
The abs() function is declared in <stdlib.h> which you've not included. GCC 4.9.2 didn't complain because the default compilation mode was C89/C90 (-std=gnu89) and functions did not need to be declared before being used in C89 as long as they returned an int, but the default compilation mode was changed...
c,gcc,casting,null,gcc-warning
Should they warn? Sure. Are they required to? No. A null pointer constant is not necessarily of pointer type; in fact it typically isn't. (Yes, this is as weird as you think it is.) A null pointer constant is either an constant integer expression with value 0, or such an...
c++,arrays,g++,compiler-warnings,gcc-warning
The reason is quite simple: for your filename[0] the compiler can use your operator[], or it can convert filename to char* using your type conversion operator, and then apply operator[] to a char pointer. More explicitly, what happening is filename.Array<char>::operator[](0) vs filename.Array<char>::operator char*().operator[](0) (don't know whether the latter is correct...
This is best done with the __attribute__((unused)) GCC extension, as in the code below: namespace { void f() __attribute__((unused)); void g(); void f() {} void g() {} } int main() {/*f(); g();*/ return 0;} ...
c,function,multidimensional-array,gcc-warning
Try #define DIMENSION 1 #include<cstdlib> void fun(double *x, double *y); int main() { double *x = NULL; double *y = NULL; x =(double*) malloc(5*sizeof(double)); #if DIMENSION == 2 y =(double*) malloc(5*sizeof(double)); #endif fun(x,y); free(x); #if DIMENSION == 2 free(y); #endif return 0; } void fun(double *x, double *y) { int...
Write a script gccflags-filter that would filter out flags inappropriate for a given language. For example python-config --cflags | gccflags-filter --lang=c++ The list of flags can be taken from the documentation. If you need a stopgap measure for your particular problem now, consider something like g++ `python-config --cflags | sed...
In theory there is no answer to your question: if what you intend to write is a no-op (on the particular architecture being targeted) for all possible values of val the code can be reached with, then the compiler can warn that it is a no-op for all… In practice,...
As a hack you can use -Doverride= on the command line. This will make it so GCC does not see override.
According to your comment you have to suport gcc 4.4. As LTO started with gcc 4.5 (with all caution about early versions), the answer should be clearly. no -flto. So, #include the code with all due caution, of course....