calebh / Juniper

https://www.juniper-lang.org/
MIT License
79 stars 9 forks source link

Problems Getting Blink.jun Uploaded to Arduino #8

Closed morgankenyon closed 2 years ago

morgankenyon commented 3 years ago

First time Juniper developer here. I'm having problems getting the simple blink.jun program uploaded to my board. Here's the problems I'm running into.

I've installed Juniper (version 3.0) and am running the following code:

module Blink
open(Prelude, Io, Time)

//It wouldn't compile without me specifying the `uint16` type
let boardLed: uint16 = 13

let tState = Time:state()
let ledState = ref low()

fun loop() = (
    let timerSig = Time:every(1000, tState);
    let ledSig =
        Signal:foldP(
            fn (currentTime, lastState) ->
                Io:toggle(lastState)
            end,
            ledState, timerSig);
    Io:digOut(boardLed, ledSig)
)

fun setup() =
    Io:setPinMode(boardLed, Io:output())

I am able to successfully compile using the Juniper CLI:

image

Ouput main.cpp

(Independently I've installed PlatformIO, and can copy their simple blink to my board and run it.)

I'm writing the output of the Juniper build into the main.cpp of my PlatformIO project. But when I build the PlatformIO project, I get a lot of warnings and the following errors.

image

src\main.cpp:333:13: error: no matching function for call to 'operator new(sizetype, void*&)'
src\main.cpp:266:17: error: no matching function for call to 'operator new(sizetype, void*&)'
//lots more of this error

Full Build Output

Do you have any guidance on how to resolve these errors?

morgankenyon commented 3 years ago

I'm also running Juniper 3.0.

image

I realize this could be some misconfiguration issue with PlatformIO, but I'm having a hard time finding an end to end example of getting Juniper to run on Arduino.

calebh commented 2 years ago

It looks like the header was not added to the C++ project. This is required to use the placement new C++ operator as Juniper uses it. Try adding the following line at the top of your C++ file:

#include <new>

I also see that the generated code is in C++17 and not C++11. I'm going to see what I can do for moving the required C++ language version back down to 11 to maintain maximum compatibility.