Skip to content

Instantly share code, notes, and snippets.

@studoot
Created June 17, 2020 18:07
Show Gist options
  • Save studoot/2f7a3293f6e6ea63d318fba34d3faf42 to your computer and use it in GitHub Desktop.
Save studoot/2f7a3293f6e6ea63d318fba34d3faf42 to your computer and use it in GitHub Desktop.
Issue with xxhash_cpp
#include "xxhash.hpp"
#include <iostream>
extern void process();
int main(int, char **)
{
process();
std::cout << "xxhash<32>(1) => " << xxh::xxhash<32>(std::array<uint32_t, 1>{1}) << std::endl;
}
#include "xxhash.hpp"
#include <iostream>
void process()
{
std::cout << "xxhash<32>(1) => " << xxh::xxhash<32>(std::array<uint32_t, 1>{1}) << std::endl;
}
@studoot
Copy link
Author

studoot commented Jun 17, 2020

Build the two files by putting them and xxhash.hpp from this commit in a directory & using the command

cl.exe a.cpp b.cpp -EHsc -std:c++17 

You should see the following output:

Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27041 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

a.cpp
b.cpp
Generating Code...
Microsoft (R) Incremental Linker Version 14.16.27041.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:a.exe
a.obj
b.obj
b.obj : error LNK2005: "void __cdecl xxh::intrin::prefetch(void const *)" (?prefetch@intrin@xxh@@YAXPEBX@Z) already defined in a.obj
a.exe : fatal error LNK1169: one or more multiply defined symbols found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment