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

Support the use of volatile #59

Open
seba-eng opened this issue Oct 3, 2018 · 2 comments
Open

Support the use of volatile #59

seba-eng opened this issue Oct 3, 2018 · 2 comments
Assignees
Labels
Feature Request This issue is a request for a particular feature Minor This change is a minor addition

Comments

@seba-eng
Copy link

seba-eng commented Oct 3, 2018

the keyword volatile doesn't seem to work which makes things like benchmarking quite difficult.
minimal example:
#include <FixedPoints.h>
#include <FixedPointsCommon.h>

void setup() {
volatile SFixed<7, 8> f1, f2, f3;
f3=f1+f2;
}

void loop() {
}

this produces the error:

no match for 'operator+' (operand types are 'volatile SFixed<7u, 8u>' and 'volatile SFixed<7u, 8u>')

Or am I just doing it wrong?

@Pharap Pharap self-assigned this Oct 3, 2018
@Pharap
Copy link
Owner

Pharap commented Oct 3, 2018

I hadn't expected anyone to need volatile versions.
Usually volatile is used for multi-threading, interrupts or special IO registers.

It should be easy enough to add volatile versions of the free functions, e.g.

template< unsigned Integer, unsigned Fraction >
constexpr SFixed<Integer, Fraction> operator +(const volatile SFixed<Integer, Fraction> & left, const volatile SFixed<Integer, Fraction> & right)
{
	using InternalType = typename SFixed<Integer, Fraction>::InternalType;
	return SFixed<Integer, Fraction>::fromInternal(static_cast<InternalType>(left.getInternal() + right.getInternal()));
}

But I don't know when I'll get chance to add them myself,
a lot of my time is currently taken up with other things.

@teuthid
Copy link

teuthid commented Dec 16, 2018

volatile is strongly neccesary if a given variable can be modified from the main program and from the interrupt(s) - quite a common phenomenon in programming for Arduino

@Pharap Pharap added Feature Request This issue is a request for a particular feature Minor This change is a minor addition labels Mar 25, 2021
@Pharap Pharap changed the title volatile doesn't work Support the use of volatile Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This issue is a request for a particular feature Minor This change is a minor addition
Projects
None yet
Development

No branches or pull requests

3 participants