Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[windows] Linking two files with <windows.h> included generates "already defined" errors #12413

Closed
timurrrr opened this issue Feb 20, 2012 · 6 comments
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category duplicate Resolved as duplicate

Comments

@timurrrr
Copy link
Contributor

Bugzilla Link 12041
Resolution DUPLICATE
Resolved on May 06, 2012 21:52
Version trunk
OS Windows NT
Blocks llvm/llvm-bugzilla-archive#12477
CC @asl,@tritao

Extended Description

$ more file1.c:
#include <windows.h>
int main(void) { return 0; }

$ more file2.c
#include <windows.h>

$ clang.exe --version
clang version 3.1 (trunk 150957)
Target: i686-pc-win32
Thread model: posix

$ clang.exe file1.c file2.c
file2-489042.o : error LNK2005: _Int64ShllMod32@12 already defined in file1-489041.o
file2-489042.o : error LNK2005: _Int64ShraMod32@12 already defined in file1-489041.o
file2-489042.o : error LNK2005: _Int64ShrlMod32@12 already defined in file1-489041.o
file2-489042.o : error LNK2005: _InterlockedBitTestAndSet already defined in file1-489041.o
file2-489042.o : error LNK2005: _InterlockedBitTestAndReset already defined in file1-489041.o
file2-489042.o : error LNK2005: _InterlockedBitTestAndComplement already defined in file1-489041.o
file2-489042.o : error LNK2005: _MemoryBarrier already defined in file1-489041.o
file2-489042.o : error LNK2005: _ReadPMC already defined in file1-489041.o
file2-489042.o : error LNK2005: _ReadTimeStampCounter already defined in file1-489041.o
file2-489042.o : error LNK2005: _DbgRaiseAssertionFailure already defined in file1-489041.o
file2-489042.o : error LNK2005: _HEAP_MAKE_TAG_FLAGS already defined in file1-489041.o
file2-489042.o : error LNK2005: _RtlSecureZeroMemory already defined in file1-489041.o
file2-489042.o : error LNK2005: _TpInitializeCallbackEnviron already defined in file1-489041.o
file2-489042.o : error LNK2005: _TpSetCallbackThreadpool already defined in file1-489041.o
file2-489042.o : error LNK2005: _TpSetCallbackCleanupGroup already defined in file1-489041.o
file2-489042.o : error LNK2005: _TpSetCallbackActivationContext already defined in file1-489041.o
file2-489042.o : error LNK2005: _TpSetCallbackNoActivationContext already defined in file1-489041.o
file2-489042.o : error LNK2005: _TpSetCallbackLongFunction already defined in file1-489041.o
file2-489042.o : error LNK2005: _TpSetCallbackRaceWithDll already defined in file1-489041.o
file2-489042.o : error LNK2005: _TpSetCallbackFinalizationCallback already defined in file1-489041.o
file2-489042.o : error LNK2005: _TpSetCallbackPriority already defined in file1-489041.o
file2-489042.o : error LNK2005: _TpSetCallbackPersistent already defined in file1-489041.o
file2-489042.o : error LNK2005: _TpDestroyCallbackEnviron already defined in file1-489041.o
file2-489042.o : error LNK2005: _InterlockedAnd64 already defined in file1-489041.o
file2-489042.o : error LNK2005: _InterlockedOr64 already defined in file1-489041.o
file2-489042.o : error LNK2005: _InterlockedXor64 already defined in file1-489041.o
file2-489042.o : error LNK2005: _InterlockedIncrement64 already defined in file1-489041.o
file2-489042.o : error LNK2005: _InterlockedDecrement64 already defined in file1-489041.o
file2-489042.o : error LNK2005: _InterlockedExchange64 already defined in file1-489041.o
file2-489042.o : error LNK2005: _InterlockedExchangeAdd64 already defined in file1-489041.o
file2-489042.o : error LNK2005: _InitializeThreadpoolEnvironment already defined in file1-489041.o
file2-489042.o : error LNK2005: _SetThreadpoolCallbackPool already defined in file1-489041.o
file2-489042.o : error LNK2005: _SetThreadpoolCallbackCleanupGroup already defined in file1-489041.o
file2-489042.o : error LNK2005: _SetThreadpoolCallbackRunsLong already defined in file1-489041.o
file2-489042.o : error LNK2005: _SetThreadpoolCallbackLibrary already defined in file1-489041.o
file2-489042.o : error LNK2005: _SetThreadpoolCallbackPriority already defined in file1-489041.o
file2-489042.o : error LNK2005: _SetThreadpoolCallbackPersistent already defined in file1-489041.o
file2-489042.o : error LNK2005: _DestroyThreadpoolEnvironment already defined in file1-489041.o
file2-489042.o : error LNK2005: _HRESULT_FROM_WIN32 already defined in file1-489041.o
a.out : fatal error LNK1169: one or more multiply defined symbols found
clang: error: linker command failed with exit code 1169 (use -v to see invocation)

@asl
Copy link
Collaborator

asl commented Feb 20, 2012

iirc this was because these functions should be __forceinline or something like this.

@timurrrr
Copy link
Contributor Author

Looking at <WinNT.h> (SDK v7.0),
these functions are FORCEINLINE, which in turn is
#define FORCEINLINE __forceinline

@timurrrr
Copy link
Contributor Author

Adding
... -D__forceinline="attribute((always_inline)) static"
-D__inline="attribute((inline)) static"
to the command line helps.

See also
http://clang-developers.42468.n3.nabble.com/clang-static-inline-and-windows-h-td2957036.html

@tritao
Copy link
Mannequin

tritao mannequin commented May 7, 2012

*** This bug has been marked as a duplicate of bug #9649 ***

@timurrrr
Copy link
Contributor Author

mentioned in issue llvm/llvm-bugzilla-archive#12477

@tritao
Copy link
Mannequin

tritao mannequin commented Nov 27, 2021

mentioned in issue #9649

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

2 participants