I searched in the programming guide, maybe I missed something, I didnt find it. I made a basic try and seems that as gcc, nvcc gives same error message. (same code g++ works)
main.c:2: error: expected ‘;’, ‘,’ or ‘)’ before ‘=’ token
There are no silly questions. Are you trying to use a function with a default argument in the host code portion of your CUDA code, or in device code? What CUDA version are you using? It would be helpful if you could post your (presumably very minimal) repro case. I am trying to find out from the compiler team what is and isn’t supported in this regard, as I haven’t tried to use default arguments in my own CUDA code and thus have no experience with that.
[Later:] just noticed the error messages refers “main.c”, i.e. C code. CUDA code should be in files with a .cu file exension. The intermediate files produced by NVCC are all .cpp (C++) files, best I know.
Thank you for reply, after change the filename as .cu, it works.
My host code files (.c) and kernel code files (.cu) are separated in the source package, I wish to use default argument in my host code but I wish to use nvcc for whole package. Is it possible for me to still use .c for host part and at the same time have support for default argument?
Default arguments are a feature of C++ (and in as much as CUDA supports C++ features, of CUDA), but they are not supported in standard C. So you will be able to use functions with default arguments in .cpp and .cu files, but not .c files. You might consider moving your host code to a .cpp file. Since C++ contains most of C as a subset, you will probably be able to convert the code with minimal or no changes.