PRB: Writing Optimized Dynamic Link Libraries (DDLs)

ID Number: Q57939

5.10 6.00 6.00a

OS/2

Summary:

SYMPTOMS

In Microsoft C versions 5.1, 6.0, and 6.0a, there is no problem

building an /Od version of a DLL. However, building an /Ox

optimized version will cause the following error to be generated

during linking if the alternate math library is being used:

LINK : error L2029: Unresolved externals:

__CIsin in file(s):

FILE.OBJ(file.c)

CAUSE

The problem is caused by the compiler optimizing with intrinsics

(/Oi). The function you get the unresolved external on is the

intrinsic version of sin(). LLIBCDLL and all the alternate math

libraries do not include ANY intrinsic math functions.

RESOLUTION

To work around this there are two options:

1. Compile with /Oalt. This is the easiest because it requires no

code changes.

2. Add the following line to your code for each function that is

not in LLIBCDLL and you can use /Ox for maximum possible

optimization:

#pragma function({func1} {func2}...{funcN})

This tells the compiler to use the standard version instead of

the intrinsic version of these functions.

More Information:

For more information on the function pragma, see page 94 in the

"Microsoft C Optimizing Compiler: User's Guide" for C 5.1 and see page

11-12 of the "Microsoft C Advanced Programming Techniques" manual for

C 6.0.

Additional reference words: 5.10 6.00 6.00a 6.00ax