确定文件是否由Qt Creator解析(CUDA语法突出显示) [英] Determining if a file is parsed by Qt Creator (CUDA Syntax highlighting)
问题描述
我最近从Visual Studio切换到了Qt Creator。我仍在Windows上使用Visual Studio编译器,因为CUDA将此作为依赖项。 CUDA使用的某些函数和关键字仅在由nvcc编译时才有效,因此我在Visual Studio中进行了一种解决方法,以便为CUDA文件启用语法高亮显示:
I switched recently from Visual Studio to Qt Creator. I am still using the Visual Studio Compiler on Windows as CUDA has this as a dependency. CUDA uses some functions and keywords that are only valid when compiled by nvcc, so I did a workaround in Visual Studio to enable syntax highlighting for CUDA files:
#pragma once
#ifdef __INTELLISENSE__
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#define __CUDACC__
#include <device_functions.h>
#endif
这在Visual Studio中作为预处理器宏 __ INTELLISENSE __
仅在Visual Studio自身解析文件时定义,而不是在编译期间定义。现在我想知道Qt Creator在解析过程中是否还有一个宏,这样编码CUDA的解决方法仍然有效。
This works in Visual Studio as the preprocessor macro __INTELLISENSE__
is only defined when Visual Studio itself parses the file, not during compilation. Now I wanted to know if there is also a macro that Qt Creator defines during parsing so that this workaround for coding CUDA still works.
谢谢
Sven
Thanks Sven
推荐答案
尝试
#ifdef Q_CREATOR_RUN
// ...
#endif
这篇关于确定文件是否由Qt Creator解析(CUDA语法突出显示)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!