# #include <curand_kernel.h> gives errors

When I include curand_kernel.h I get the following errors during compile on Windows 10.

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin/…/include\cuda.h(1837): error: expected a “)”
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin/…/include\cuda.h(15259): error: expected a “)”
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin/…/include\cuda.h(15301): error: expected a “)”
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin/…/include\cuda.h(15353): error: expected a “)”
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin/…/include\cuda.h(15399): error: expected a “)”
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin/…/include\cuda.h(15422): error: expected a “)”

Compile command:
nvcc -DWIN64 --gpu-architecture=compute_35 --gpu-code=compute_35,sm_35 --shared --use_fast_math

I searched this for a while but could not find any solutions or similar problems.

If you’re including this in a file that ends in .cpp, then that is a mistake. Otherwise you need to provide a more complete example, and it may be that your CUDA install is broken.

All files end in .cu
I will try reinstalling the Toolkit, thank you

Error resolved by moving #include <curand_kernel.h> all the way to the top, above .cuh includes!
{"extraction_info": {"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.8417847156524658, "perplexity": 18357.77501821758}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2022-40/segments/1664030334596.27/warc/CC-MAIN-20220925193816-20220925223816-00616.warc.gz"}