www.digitalmars.com Home | Search | CTG | RTL | IDDE | STL
Last update Sat Apr 8 23:54:05 2006
Compiler & Tools Guide

Compiling
Compiling Code
C Implementation
C++ Implementation
Language Extensions
Mixing Languages
Assembly Language
Inline Assembler
Optimizing Code
Numerics Programming
Regular Expressions
Acrtused
Pragmas
Precompiled Headers
Predefined Macros
Warning Messages
Error Messages
Runtime Messages


Linking
Optlink
Switches
Module Definition Files
Operation and Design
Error Messages


Win32 Programming
Win32 Programming


DOS and Win16
Programming

Memory Models
16 Bit Pointer Types
and Type Modifiers

Handle Pointers
DOS
DOS 32 (DOSX)
Win16
Win16 DLLs
Win16 Prolog/Epilog


C/C++ Extensions
Contract Programming
__debug statement
__debug declaration
Dynamic Profiling
Embedding C in HTML


Tools
BCC
CHMOD
CL
COFF2OMF
COFFIMPLIB
DMC
DIFF
DIFFDIR
DUMP
DUMPOBJ
DUMPEXE
EXE2BIN
FLPYIMG
GREP
HC
IMPLIB
LIB
LIBUNRES
MAKE
MAKEDEP
ME
OBJ2ASM
PATCHOBJ
RC
RCC
SC
SHELL
SMAKE
TOUCH
UNMANGLE
WHEREIS


Porting to DMC++
Switching to DMC++
from Microsoft
from Borland
Porting Guide


Acrtused

__acrtused is an external reference generated by the compiler to bring in the startup code appropriate to a console application, a Windows application, a DLL, or a WINC application. Different __acrtused names are referenced to bring in different startup code.

Programmers occasionally run into various problems with _acrtused names being multiply defined or being undefined. Essentially, _acrtused is an external reference generated by the compiler in order to bring in the startup code appropriate to a console app, a windows app, a dll app, etc. Different acrtused names are referenced to bring in different startup code. The variations are:

__acrtused      If WinMain()
			-or-
		If 16 or 32 bit DOS compile and main()

__acrtused_winc If 16 bit Windows compile and main()

__acrtused_dll  If 16 bit Windows compile and LibMain()
			-or-
		If -mn and LibMain()
			-or-
		If -mn and DllMain()

__acrtused_con  If -mn and main()

__wacrtused_con If -mn and wmain()

__wacrtused     If -mn and wWinMain()
Notes:
  • Detection of main() and DllMain() are done in a case- sensitive manner, WinMain() and LibMain() are done in a case-insensitive manner.
  • By "16 bit Windows compile", that means compiling with a 16 bit memory model, and the -W switch or -W[123ADx].
  • -mn means a Win32 program.

Troubleshooting problems with startup code at link time

  • Message about "__acrtused_??? undefined" from the linker:
    • The most likely cause is not linking with the standard runtime library (RTL) for the memory model specified.
    • Check that /NOD (no default library search) is not specified for the linker.
    • Check that the environment variable LIB (or the LIB in sc.ini) is set to point to the directory where the runtime libraries are (which is typically c:\sc\lib).
    • Check that -NL (no default library) is not specified to the compiler.
    • Check that only one of main(), WinMain(), LibMain() and DllMain() is defined in your program.
    • Check that the module being compiled with main(), etc., is compiled with Digital Mars C/C++ and not some other compiler.
    • Check that you are not linking with the runtime library from another compiler.
    • Run the utility OBJ2ASM on the object (.obj) files, and search the output to see who is referencing __acrtused_???.

  • Linker message about "identifier previous definition different", or "multiply defined", and identifier is an internal name to the runtime library:
    • The most likely cause is that more than one of main(), WinMain(), LibMain() and DllMain() is being defined, so that more than one startup code module is pulled in, resulting in the name collisions.
    • Try linking with /NOD and note the unresolved externals and which modules refer to them. If things are really desperate, try pulling the startup code out of the standard runtime libary (making a backup of the original first!) and check to see what symbols are left unresolved. This will tell you who is trying to pull in the extra set of startup code.