问题描述
当我在Microsoft Visual Studio 2010中编辑 .cu 文件时,编辑器将其视为常规文本文件(关键字没有颜色,例如 int , float 等关闭括号不高亮显示)。
如何在Visual Studio中启用 .cu 文件的语法高亮,以便编辑 .cu 文件就像编辑常规C / C ++文件?
在Visual Studio中,在c ++扩展下添加.cu 。编辑:在工具 - >选项 - >文本编辑器 - >文件扩展名键入cu并选择Microsoft Visual C ++作为编辑器,然后单击添加
要添加CUDA关键字语法高亮,您可以搜索 usertype.dat 在您的CUDA安装文件夹(确保它没有找到在Program Files文件夹中搜索它在您的主文件夹 - > AppData - > Local - > NVIDIA Corporation (抱歉,我没有提供详细信息,因为我现在没有Windows),然后将其复制到 Program Files \\ \\ Microsoft Visual Studio 10.0 \Common7\IDE 并重新启动Visual Studio
但是,但仍然可能无法正常工作,最后用AFAIK您可以使用Visual Assistant x,然后你必须更改它的设置如下:
对于VS2010,VS2008,VS2005和VS.NET: p>
将您的扩展名添加到:
C ++文件扩展(VS.NET)
工具|选项|项目和解决方案| VC ++项目设置| C / C ++文件扩展名(VS2005,VS2008)
选项|项目和解决方案| VC ++项目设置|要包括的扩展(VS2010)
退出IDE并使用regedit将以下条目克隆到扩展中结尾的类似条目: / p>
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Languages\File Extensions\.cpp
如果您使用64位操作系统,请克隆注册表项:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\8.0\ Languages\File Extensions\.cpp
如果您的扩展表示一个头,使用 regedit 在以下位置将扩展添加到 ExtHeader 。请记住加入点和结束分号:
HKEY_CURRENT_USER\软件\Whole Tomato \Visual Assist X \VANet8
如果您的扩展名表示不是头文件的源文件,请将扩展名添加到 ExtSource 以下位置。
HKEY_CURRENT_USER\软件\Whole Tomato \Visual助手X\VANet8
在Visual Assist X选项对话框的性能选项卡上按重建,然后重新启动IDE。
替换 8.0 如果您使用VS 2010,则 10.0 。
替换 8.0 用替换 8.0 7.1 如果您使用VS.NET 2003.
将替换为 7.0 使用VS.NET 2002.
使用 VANet10 > for Visual Studio 2010.
如果您使用VS2008,请将替换为与 VSNet9 。
如果使用VS.NET 2003,请将替换为与 VSNet 。
替换 VANet8 与 VANet7 .0如果您使用VS.NET 2002。
对于VC ++ 6.0:
退出IDE并使用 regedit 将扩展名添加到:
HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Text Editor\Tabs / Language Settings\C / C ++ \FileExtensions 。
如果您的扩展名表示头,请使用 regedit 将扩展名添加到 ExtHeader 在以下位置。请记住加入点和结束分号:
HKEY_CURRENT_USER\软件\Whole Tomato \Visual Assist X \VA6
如果您的扩展名表示不是头文件的源文件,请将扩展名添加到 ExtSource 请注意包含点和结束分号:
HKEY_CURRENT_USER\软件\Whole Tomato \Visual Assist X \VA6
在Visual Assist X选项对话框的性能选项卡上按重建,然后重新启动IDE。
When I edit a .cu file in Microsoft Visual Studio 2010, the editor treats it as a regular text file (there are no colors on keywords such as int, float etc. Closing brackets are not highlighted).
How do I enable syntax highlighting of .cu files in Visual Studio, so that editing .cu files is like editing regular C / C++ files?
Adding '.cu' under c++ extension in visual studio settings would enable syntax highlighting for c++ keywords only. EDIT: It in Tools -> Options -> Text Editor -> File Extension type in cu and select Microsoft Visual C++ as the editor and click add
To add CUDA keyword syntax highlighting you can search for usertype.dat in your CUDA installation folders (make sure if it is not found in the Program Files folder to search for it in your home folder -> AppData-> Local -> NVIDIA Corporation (sorry that I'm not providing the details since I don't have Windows right now), then copy it to Program Files\Microsoft Visual Studio 10.0\Common7\IDE and restart Visual Studio
But, But! still it might not work, so what you are ended up with AFAIK you can use Visual Assistant x and then you have to change it's settings as follows:
For VS2010, VS2008, VS2005 and VS.NET:
Add your extension to:
Tools | Options | Projects | VC++ Build | C/C++ File Extensions (VS.NET)
Tools | Options | Projects and Solutions | VC++ Project Settings | C/C++ File Extensions (VS2005, VS2008)
Tools | Options | Projects and Solutions | VC++ Project Settings | Extensions To Include (VS2010)
Exit the IDE and use regedit to clone the following entry to a like entry that ends in your extension:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Languages\File Extensions\.cpp
If you are using a 64bit OS then clone the registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\8.0\Languages\File Extensions\.cpp
If your extension denotes a header, use regedit to add the extension to ExtHeader in the following location. Remember to include the dot and terminating semicolon:
HKEY_CURRENT_USER\Software\Whole Tomato\Visual Assist X\VANet8
If your extension denotes a source file that is not a header, add the extension to ExtSource in the following location.
HKEY_CURRENT_USER\Software\Whole Tomato\Visual Assist X\VANet8
Press Rebuild on the Performance tab of the Visual Assist X options dialog and restart your IDE.
Replace 8.0 with 10.0 if you use VS 2010.Replace 8.0 with 9.0 if you use VS 2008.Replace 8.0 with 7.1 if you use VS.NET 2003.Replace 8.0 with 7.0 if you use VS.NET 2002.
Replace VANet8 with VANet10 for Visual Studio 2010.Replace VANet8 with VSNet9 if you use VS2008.Replace VANet8 with VSNet if you use VS.NET 2003.Replace VANet8 with VANet7.0 if you use VS.NET 2002.
For VC++ 6.0:
Exit your IDE and use regedit to add the extension to:
HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Text Editor\Tabs/Language Settings\C/C++\FileExtensions.
If your extension denotes a header, use regedit to add the extension to ExtHeader in the following location. Remember to include the dot and terminating semicolon:
HKEY_CURRENT_USER\Software\Whole Tomato\Visual Assist X\VA6
If your extension denotes a source file that is not a header, add the extension to ExtSource in the following location.Remember to include the dot and terminating semicolon:
HKEY_CURRENT_USER\Software\Whole Tomato\Visual Assist X\VA6
Press Rebuild on the Performance tab of the Visual Assist X options dialog and restart your IDE.
这篇关于如何在Visual Studio 2010中启用CUDA .cu文件的语法高亮显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!