I found a workaround by compiling as C++ instead of C.
C:\Users\RLWA32\source\repos\Rlwa32\FooLib\FooLib>cl /c /MD /Tp FOOBar.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30143 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
FOOBar.c
C:\Users\RLWA32\source\repos\Rlwa32\FooLib\FooLib>lib /out:mylib.lib FOOBar.obj
Microsoft (R) Library Manager Version 14.29.30143.0
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Users\RLWA32\source\repos\Rlwa32\FooLib\FooLib>link /map /mapinfo:exports /def:FooLib.def /machine:x86 /DLL /out:FooLib.dll mylib.lib msvcrt.lib
Microsoft (R) Incremental Linker Version 14.29.30143.0
Copyright (C) Microsoft Corporation. All rights reserved.
LINK : warning LNK4001: no object files specified; libraries used
Creating library FooLib.lib and object FooLib.exp
C:\Users\RLWA32\source\repos\Rlwa32\FooLib\FooLib>dumpbin /exports FooLib.dll
Microsoft (R) COFF/PE Dumper Version 14.29.30143.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file FooLib.dll
File Type: DLL
Section contains the following exports for FooLib.dll
00000000 characteristics
FFFFFFFF time date stamp
0.00 version
1 ordinal base
2 number of functions
2 number of names
ordinal hint RVA name
1 0 00001C90 FOOBar
2 1 00001C90 _FOOBar
Summary
1000 .data
1000 .rdata
1000 .reloc
1000 .text
C:\Users\RLWA32\source\repos\Rlwa32\FooLib\FooLib>
FOOBar.c
#include "framework.h"
void FOOBar(void)
{
OutputDebugStringW(L"Function body for FOOBar\n");
}
Header -
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>
__declspec(dllexport) void FOOBar(void);
FooLib.def -
LIBRARY
EXPORTS
_FOOBar=?FOOBar@@YAXXZ
FOOBar=?FOOBar@@YAXXZ
Linker map -
Exports
ordinal name
1 ?FOOBar@@YAXXZ (void __cdecl FOOBar(void))
exported name: FOOBar
2 ?FOOBar@@YAXXZ (void __cdecl FOOBar(void))
exported name: _FOOBar