0

I'm pretty new to arduino and I just downloaded clion and installed the arduino plugin so I have an IDE that I'm used to. Here is my code:

#include <Arduino.h>

// Time between a switch indicating not full and the time a valve is opened
#define SWITCH_DELAY 5000

#define PIN_SWITCH 2
#define PIN_GREEN 3
#define PIN_YELLOW 4

#define INT16 int
#define UINT16 unsigned int
#define UINT32 unsigned long

DelayChecker    degassingChecker(PIN_SWITCH, PIN_GREEN);

void setup() {
    pinMode(PIN_SWITCH, INPUT);
    pinMode(PIN_GREEN, OUTPUT);
    pinMode(PIN_YELLOW, OUTPUT);

    Serial.begin(9600);
    Serial.print("UINT16: " + sizeof(UINT16));
    Serial.print("UINT32: " + sizeof(UINT32));
}

void loop() {
    UINT32 now = millis();

    degassingChecker.check(now);
}

public class DelayChecker {
    private:
        UINT32 delayExpires = 0;
        UINT16 switchId = 0;
        UINT16 solenoidId = 0;
        bool solenoidOn = false;

    public:
        DelayChecker(const unsigned int sw, const unsigned int sol) {
            switchId = sw;
            solenoidId = sol;
        }

        void check(const UINT32 now) {
            if (delayExpires == 0) {
                INT16 switchState = digitalRead(switchId);
                if (switchState == LOW) {
                    delayExpires = millis() + SWITCH_DELAY;
                    digitalWrite(PIN_YELLOW, HIGH);
                }
            }
            else {
                if (now >= delayExpires) {
                    INT16 switchState = digitalRead(switchId);
                    if (switchState == LOW) {
                        if (!solenoidOn) {
                            digitalWrite(solenoidId, HIGH);
                            solenoidOn = true;
                        }
                    }
                    else {
                        if (solenoidOn) {
                            digitalWrite(solenoidId, LOW);
                            solenoidOn = false;
                        }
                    }
                }
            }
        }
};

I hit the run button and get the following.

====================[ Build | untitled1 | Debug ]===============================
/opt/clion/bin/cmake/linux/bin/cmake --build /home/thomas/CLionProjects/untitled1/cmake-build-debug --target untitled1 -- -j 12
[  7%] Building C object CMakeFiles/uno_CORE.dir/opt/arduino-1.8.13/hardware/arduino/avr/cores/arduino/wiring_pulse.c.obj
[  7%] Building CXX object CMakeFiles/uno_CORE.dir/opt/arduino-1.8.13/hardware/arduino/avr/cores/arduino/new.cpp.obj
[ 10%] Building C object CMakeFiles/uno_CORE.dir/opt/arduino-1.8.13/hardware/arduino/avr/cores/arduino/wiring_shift.c.obj
/opt/arduino-1.8.13/hardware/arduino/avr/cores/arduino/new.cpp:29:46: error: expected initializer before 'noexcept'
 void * operator new(size_t size, void * ptr) noexcept {
                                              ^~~~~~~~
gmake[3]: *** [CMakeFiles/uno_CORE.dir/build.make:317: CMakeFiles/uno_CORE.dir/opt/arduino-1.8.13/hardware/arduino/avr/cores/arduino/new.cpp.obj] Error 1
gmake[3]: *** Waiting for unfinished jobs....
gmake[2]: *** [CMakeFiles/Makefile2:99: CMakeFiles/uno_CORE.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:133: CMakeFiles/untitled1.dir/rule] Error 2
gmake: *** [Makefile:151: untitled1] Error 2

It looks like an error in the libraries. Has anyone seen anything like this?

1
  • Could be some incorrect build settings by that plugin.
    – PMF
    Jan 12 at 13:57
2

I found a github issue fixing this error : https://github.com/vsch/CLionArduinoPlugin/issues/36

It worked for me

2
  • You're referring to setting the Clion project settings to use language standard to c++17?
    – timemage
    Jan 26 at 20:07
  • Yeah I'm sorry... First time for me ^^ thanks for explaining to me
    – KyabeSama
    Jan 27 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.