Menu
  • HOME
  • TAGS

Compiling and Linking pure C and CUDA code [warning: implicit declaration of function]

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__...

Suppress warning:deleting 'void*' is undefined

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,...

Compile-time assertion fails without GCC optimization

c,gcc,macros,gcc-warning,gcc4

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 -...

Compilation error at Dining philosopher semaphore

c,compilation,gcc-warning

I found your problem! check that link: http://thecodecracker.com/c-programming/dining-philosophers-problem/comment-page-1/

How can I express wait(NULL) without getting compilation warning?

c,gcc,gcc-warning

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()....

Warning: passing argument x of 'foo' from incompatible pointer type

pointers,gcc,gcc-warning

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....

Getting “format not a string literal and no format arguments” warning while using GTK+2

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...

Missing 'uninitialized' warning

c,gcc,gcc-warning

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 - iteraion 3u invokes unidenified error

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...

Some warnings being treated as errors while making a modified ver of ext2 kernel module under ubuntu

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 :)

Can't find what's wrong with this simple C code

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)...

How to make gcc complain about comparison of char with 256

c,gcc,gcc-warning

-Wtype-limits (or -Wextra) should trigger this warning

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

c,gcc-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 ...

return dynamically generated value from function

gcc,types,gcc-warning

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...

Implicit declaration of function abs - gcc-5.1.0

gcc,gcc-warning

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...

Should C compilers warn on 'char c = NULL'?

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...

Strange warnings when using my array class

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...

Disable “unused function” for specific function name

c++,gcc,gcc-warning

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;} ...

Multidimension C program structure

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...

Calling Python from C++, how to get rid of the `-Wstrict-prototypes` warning?

python,c++,gcc,gcc-warning

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...

Options for suppressing “comparison is always false due to limited range of data type” warning

c,gcc,gcc-warning

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,...

Disable check for override in gcc

c++11,gcc,gcc-warning

As a hack you can use -Doverride= on the command line. This will make it so GCC does not see override.

inlining C code : -flto or not -flto

c,gcc,clang,gcc-warning

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....