Comments (6)
Given that we want this code to work in C, and want to be as portable as possible, what do you propose as a better design?
from fastmod.
Just don't use an anonymous namespace.
from fastmod.
@jwakely If you include the header in more than one location in your project, then you are going to get several definitions for the same functions.
My own code called the function 'static' (C). This works, obviously.
However, since C++11, C++ purists want to drop 'static' in favor of unnamed namespace, which is what we have here.
So... I don't think we can drop the unnamed namespace and leave it at that. If you think I am wrong, please elaborate.
from fastmod.
Oh, I assumed the functions were already inline
. That's the solution for C++. No unnamed namespace, but inline
. Now they can be included in multiple files and defined multiple times, but you get identical definitions in each.
from fastmod.
It appears to fail with errors like...
include/fastmod.h: In function ‘uint32_t fastmod::fastmod(uint32_t)’:
include/fastmod.h:174:26: error: ‘v’ declared as an ‘inline’ variable
FASTMOD_API uint64_t v = computeM_u32(d);
from fastmod.
Closed with a PR from @jwakely
from fastmod.
Related Issues (9)
- not portable to MSVC HOT 3
- comment fix HOT 1
- Why use 128-bit integers for 32 bit operations? HOT 5
- Allow signed 32 bit division on MSVC HOT 12
- `fastdiv_s64()` and `fastmod_s64()` appear to be missing? HOT 2
- Typo in fastmod.h HOT 1
- Error for MSVC (__umulh is not a constexpr function) HOT 2
- Division by 1 returns 0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastmod.