LNK4039 Warnings

Problem

When building VxDs according to instructions and examples in the Windows 95 DDK, programmers are typically presented with warning messages from the linker. The number of warning messages and their details may vary between projects and even between builds of the same project. Examples are:

The linker that generated these warnings is Microsoft’s COFF linker, as supplied with the Windows 95 DDK and with versions of Microsoft Visual C++ that generate 32-bit code. Similar warning messages are likely to be raised when the same input files are given to other COFF linkers.

In documentation for some VxD samples provided with the Windows 95 DDK, Microsoft advises programmers that the warnings “are expected and can be ignored.” Of course, many programmers are not happy just to ignore warning messages from their tools—at least not without understanding precisely which warning messages are expected as part of the programming environment and which may genuinely indicate something that the programmer has not got quite correct.

Resolution

In projects with source code either entirely in assembly language or entirely in C, the LNK4039 warnings can be eliminated from the build by careful design of the module definition file. Attention centres on lines under the SECTIONS heading, specifically to provide only for sections that are actually defined in the source files.

VxDs with Assembly Language

If a VxD project includes any assembly language source file, then many sections are defined just as a consequence of having included the VMM.INC header file. It is common practice, and indeed desirable, to have a standard (or generic) module definition file provide for all these sections, even for sections for which no code or data is actually emitted.

Some of the Windows 95 DDK’s samples, and most notably the GENERIC sample, present module definition files that also provide for six sections that will be defined only if the project includes the MSGMACRO.INC header. The names of these sections are _LMSGTABLE, _LMSGDATA, _IMSGTABLE, _IMSGDATA, _PMSGTABLE and _PMSGDATA. If the project does not contain a source file that includes MSGMACRO.INC, then to avoid six LNK4039 warnings, delete from the module definition file any lines that correspond to those message table and message data sections.

VxDs Entirely in C

By contrast with the assembly-language case, inclusion of VMM.H in VxD source written in C does not itself define any sections. The inclusion merely defines macros that will in turn define the sections if those macros are ever used. To avoid LNK4039 warnings, the module definition file should provide only for the standard segments _TEXT, _DATA, CONST and _BSS, and for segments that are actually used in the C-language source code.

This page was extracted from LNK4078 Warnings on 3rd March 1998. The last signficant modification was on 3rd March 1998.

Copyright © 1997-98. Geoff Chappell. All rights reserved.

[Home][Programming Samples][Application Notes][Security Notes][Editorial][Consultation][Contacts]