DOCUMENT:Q121289 25-JUL-2001 [visualc] TITLE :PRB: Unreferenced Symbols Don't Appear in .BSC File PRODUCT :Microsoft C Compiler PROD/VER::1.0,1.5,1.51 OPER/SYS: KEYWORDS:kbprb ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual C++, versions 1.0, 1.5, 1.51 ------------------------------------------------------------------------------- SYMPTOMS ======== Unless a symbol is referenced in a program, it will not appear in the browser database. CAUSE ===== This problem is due to the default behaviors of the Compiler (CL.EXE) and how it handles browser files (.SBR files), as well as the Browser Database Maintenance Utility (BSCMAKE.EXE) and how it handles browser databases (.BSC files). NOTE: This article does not apply to Microsoft Visual C++, 32-bit Edition, version 2.0 and above. In these versions, when the compiler option "Don't Pack Info" is selected, the option /Zn is added to the CL compile line. Subsequently, the option /Iu is automatically added to BSCMAKE.EXE. RESOLUTION ========== By understanding the default behaviors, you can discover where unreferenced symbols are defined. The default behavior of the Compiler when using the /FR or /Fr switches is to pack browser files, removing information about where unreferenced symbols are defined. To prevent the Compiler from doing this packing, use the /Zn switch from the command line, or check the "Don't Pack Information" checkbox under: Options...|Project...|Compiler...|Listing Files Similarly, the default behavior of BSCMAKE is to not record information about unreferenced symbols when building the browser database for an application. To turn off this behavior, use the /Iu switch from the command line. NOTE: There is no way to control BSCMAKE's behavior when using a Visual Workbench-generated makefile. The hard-coded default BSCMAKE command line used by the Visual Workbench doesn't include the /Iu option. In the case of a Visual Workbench-generated makefile, find the inference rule within the makefile generated by the Visual Workbench that causes the BSCMAKE utility to be executed. There, change the command line that is passed to the BSCMAKE utility. To do this, open the makefile as a text file and find the $(PROJ).BSC: inference rule. You should see the BSCMAKE command on the next line or two. Just add the /Iu option as shown in this example: $(PROJ).BSC: $(SBRS) bscmake@<< /Iu /o$@ $(SBRS) << NOTE: There is an important caveat here. When you use the internal build engine of the Visual Workbench, the inference rule portion of the makefile is not used. Instead, the Visual Workbench uses the inference rules only when the file is opened as an external makefile. For this solution to work, the makefile must be opened as an external makefile in the Visual Workbench or the project must be built with NMAKE from the command line. NOTE: The Compiler and BSCMAKE work independently. BSCMAKE builds the browser database from browser (.SBR) files generated at compile time. Unreferenced symbols will not appear in the browser database if: - CL.EXE is executed with /Fr or /FR, and without the /Zn option, regardless of whether BSCMAKE is executed with the /Iu option. Omitting the /Zn option causes browser file packing to discard information about unreferenced symbols. - CL.EXE is executed with /Fr or /FR, and /Zn, and BSCMAKE is executed without the /Iu option. Omitting the /Iu option causes BSCMAKE to ignore information about unreferenced symbols. In order for the solutions presented here to work, both of these must be true: - The Compiler must be executed with /Fr or /FR, and /Zn. - BSCMAKE must be executed with the /Iu option in the same build. MORE INFORMATION ================ An unreferenced symbol is a symbol that has been defined, but never appears in the body of code apart from its definition. Common examples of defined but unreferenced symbols are instances of CWinApp-derived classes in MFC applications and variables of any type that are not used in an application. Additional query words: 1.00 1.50 1.51 ====================================================================== Keywords : kbprb Technology : kbVCsearch kbAudDeveloper kbvc150 kbvc100 kbVC151 Version : :1.0,1.5,1.51 Issue type : kbprb ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2001.