3

I am very new to CUDA programming.. I wrote my first code and when I compiled it, it is showing me a lots of error. Can anyone tell me what is wrong

the code

#include <stdio.h> #include "cuda.h" #include <stdlib.h> __global__ void kernel(void) { } int main(int argc, char *argv[]) { kernel<<<1,1>>>(); printf("finished \n"); return 0; } 

The errors are

cuda.c:5: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ cuda.c:7: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ cuda.c: In function âmainâ: cuda.c:12: error: âkernelâ undeclared (first use in this function) cuda.c:12: error: (Each undeclared identifier is reported only once cuda.c:12: error: for each function it appears in.) cuda.c:12: error: expected expression before â<â token 

I compiled using

nvcc cuda.c

Can anyone tell me what mistake I am making....

1 Answer 1

6

nvcc runs .c files through the normal C compiler. Rename your file to cuda.cu.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.