I noticed you currently have all your function implementations in a .h file. While this may seem simpler, this can cause big issues when depending on your project.
If two different .c files include your header (even though you have #pragma once), you'll doubly define your function. This is not allowed in either C or C++.
The standard way of getting around this is to move your implementations into a .c file. You'll keep your declarations in the .h. So it'll look a bit like this:
// -------------------------------
// in your .h file
#pragma once
// your includes go here (don't forget your .h file!)
__m128i _mm_load_si128 (__m128i const* address);
__m128i _mm_loadu_si128 (__m128i const* address);
// etc.
// -------------------------------
// in your .c file
// your includes go here
__m128i _mm_load_si128 (__m128i const* address)
{
return vec_load1q (address);
}
__m128i _mm_loadu_si128 (__m128i const* address)
{
return vec_loadu1q (address);
}
In C++, you get some extra options to work around the issue
inline your functions. This doesn't really fix anything, but compilers ignore the problem when you do this. C has support for inlining, but I tried it and it didn't seem to avoid the issue.
Move your functions into a class declaration, and implement them within the class body. This actually inlines your functions, so it's really the same as #1.
I noticed you currently have all your function implementations in a .h file. While this may seem simpler, this can cause big issues when depending on your project.
If two different .c files include your header (even though you have
#pragma once
), you'll doubly define your function. This is not allowed in either C or C++.The standard way of getting around this is to move your implementations into a
.c
file. You'll keep your declarations in the.h
. So it'll look a bit like this:In C++, you get some extra options to work around the issue
inline
your functions. This doesn't really fix anything, but compilers ignore the problem when you do this. C has support for inlining, but I tried it and it didn't seem to avoid the issue.Helpful resources