GithubHelp home page GithubHelp logo

Comments (6)

lemire avatar lemire commented on July 30, 2024

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.

jwakely avatar jwakely commented on July 30, 2024

Just don't use an anonymous namespace.

from fastmod.

lemire avatar lemire commented on July 30, 2024

@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.

jwakely avatar jwakely commented on July 30, 2024

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.

lemire avatar lemire commented on July 30, 2024

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.

lemire avatar lemire commented on July 30, 2024

Closed with a PR from @jwakely

from fastmod.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.