HOWTO: Make VC++ Recognize File Extensions as C/C++ FilesLast reviewed: February 20, 1998Article ID: Q181506 |
The information in this article applies to:
SUMMARYMicrosoft's Visual C++ Integrated Development Environment (IDE) recognizes the following file extensions as C++ source files: .c, .cpp, and .cxx. In some cases, a programmer may want to use other file extensions for C++ files; for example, Unix C++ source files often use the .cc extension. Using the steps in this article, source files with other file extensions may benefit from the Visual C++ IDE's syntax coloring, automatic indentation, and other usage enhancements. This article describes how to automatically compile such files as C/C++ and associate the C++ icon with these files in Windows Explorer.
MORE INFORMATIONThe following procedure causes the Visual C++ IDE to recognize extensions other than .c, .cpp, and .cxx as a C/C++ source file. These changes involve altering registry settings. WARNING: Using Registry Editor incorrectly can cause serious, system-wide problems that may require you to reinstall Windows to correct them. Microsoft cannot guarantee that any problems resulting from the use of Registry Editor can be solved. Use this tool at your own risk. Microsoft STRONGLY recommends saving the current registry settings before starting this procedure. For additional information, please see the following articles in the Microsoft Knowledge Base (the second link applies to Windows 95 as well):
ARTICLE-ID: Q103280 TITLE : Using an Emergency Repair Disk Created by Windows NT ARTICLE-ID: Q164931 TITLE : Using Regedit to Backup Your Windows NT RegistryTo start the Registry Editor:
The following steps apply to keys and values located on the home key. In the Registry Editor, locate the user settings home key for Developer Studio. For various versions, the home key is:
5.0 (which ships with Visual Studio 97) HKEY_CURRENT_USER\Software\Microsoft\DevStudio\5.0\ 4.x HKEY_CURRENT_USER\Software\Microsoft\DeveloperThe following registry keys cause the IDE to load the C/C++ compiler tool for the specified file extensions (.cc illustrated):
Although the IDE starts the C/C++ compiler tool for the file extensions added in the steps above, the compiler needs to know whether to compile the file as C or C++. The compiler normally compiles .c files as C, and compiles .cpp and .cxx as C++. For all other extensions, the compiler needs an explicit parameter: /TC compiles files as C, /TP compiles files as C++. Each project that includes files with custom extensions needs an explicit /TC or /TP parameter. The following steps illustrate how to do this:
If necessary, a custom build step can launch the C/C++ compiler (CL.EXE) with settings specific to a single file. This is less desirable, because the custom build step requires explicitly listing all of the compiler options. See REFERENCES for online documentation of instructions on adding a custom build step.
REFERENCESVisual C++ Programmer's Guide, Compiling and Linking, Details, Compiler Reference. Visual C++, Developer Studio Environment User's Guide, Working With Projects, How Do I... Topics: Working With Projects, Customizing a Build Process.
|
Additional query words: kbdsstools
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |