You cannot include MSVS host headers into device code. That only works with headers which are distinguishing between host and device code with some defines present in the respective compilers.
printf implementation you want inside the device code must come from a CUDA header.
If you search for
printf inside the CUDA toolkit include headers, you’ll find it declared inside
common_functions.h which is a header you must not include directly, but instead include the header
cuda_runtime.h inside your device code.
Means your OptiX device code source file should contain this:
and then all OptiX and CUDA device functions should work in your device code.
The same includes can be used in host code to be able to share functions on host and device if they are properly implemented for both with
If you search through the OptiX SDK 7.2.0 source code you find the
cuda_runtime.h include as well in headers used on the device side, for example inside
OptiX SDK 7.2.0\SDK\optixWhitted\helpers.h.
Which CUDA Toolkit version are you using?
For OptiX 7.2 I would recommend CUDA 11.1 because that’s the version it’s built with (see OptiX Release Notes).