We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
I include <atomic>
I use functions test_and_set() and clear().
Programming language C++14 and my compiler is armclang 6.18 I get the errors:
Some recommendations or suggestions?
Thank you in advance
Hello, could you provide a full source example, as well as the command line(s) used.
Also FYI, the latest version of Arm Compiler for Embedded is 6.22.
See also:
https://developer.arm.com/documentation/101754/0618/Supporting-Information-Appendix/Standard-C---Implementation-Definition/Atomic-operations-library
I don't use any special compiler or linker flags regarding the atomic library. I use it in code like this:
header file:
#include <atomic>
namespace some_namespace{class SomeClass{public: SomeClass(std::atomic_flag* ExclusiveOperation = nullptr) : exclusiveOperation(ExclusiveOperation) {} void someFunction(void);private: void anotherFunction(void); std::atomic_flag* const exclusiveOperation{nullptr};};}
cpp file that implements class functions:
#include "header_file.hpp"
namespace some_namespace{void SomeClass::someFunction(void){ if(exclusiveOperation != nullptr && exclusiveOperation->test_and_set()) {}}
void SomeClass::anotherFunction(void){ if(exclusiveOperation != nullptr)
{
exclusiveOperation->clear();
}
cpp file where class instance is created:
std::atomic_flag exclusiveOperation = ATOMIC_FLAG_INIT;SomeClass someClassInstance(&exclusiveOperation);
maybe it is related to this issue: github.com/.../73361
Hi Pavol, sorry for slow reply, I had to do some investigation.
The libatomic library is not provided, hence the link time errors.
Can you build with the compiler option -ffreestanding, to enable the compiler to generate appropriate code without relying on such a library call? I'm not sure if this is available with 6.18 of the compiler, it is only documented for 6.21 or later. The current compiler version is 6.22.
https://developer.arm.com/documentation/101754/0622/armclang-Reference/armclang-Command-line-Options/-ffreestanding
You can download the latest compiler version from the below.
https://developer.arm.com/documentation/ka005198