Shalom, I was using the nim-platformio and when I import strformat gives the error: Error: system module needs: getCurrentException
works
import pkg/arduino
setup:
pinMode(LED_BUILTIN, OUTPUT)
loop:
digitalWrite(LED_BUILTIN, HIGH)
delay(1000)
digitalWrite(LED_BUILTIN, LOW)
delay(1000)
but when I add this, it doesn't works
from std/strformat import fmt
static:
echo fmt"""Hello {"World"}"""
the nim-platformio platformio dependency compiles the nim with: nim cpp --path:/path/to/project/.pio/libdeps/nanoatmega328 --nimcache:/path/to/project/src/nimcache --compileOnly --cpu:avr --deadCodeElim --os:standalone --noMain --gc:none --stacktrace:off --profiler:off /path/to/project/src/mainMaybe related: https://github.com/nim-lang/Nim/issues/16404
But when using --gc:arc --os:any -d:StandaloneHeapSize=1048576, the error is:
src/nimcache/stdlib_system.nim.cpp:6:10: fatal error: exception: No such file or directory
#include <exception>
^~~~~~~~~~~
compilation terminated.
*** [.pio/build/nanoatmega328/src/nimcache/stdlib_system.nim.cpp.o] Error 1
and when compiled with --gc:arc --os:any -d:useMalloc, the error is:
src/nimcache/stdlib_system.nim.cpp:6:10: fatal error: exception: No such file or directory
#include <exception>
^~~~~~~~~~~
compilation terminated.
Indexing .pio/build/nanoatmega328/libFrameworkArduinoVariant.a
Compiling .pio/build/nanoatmega328/FrameworkArduino/CDC.cpp.o
Compiling .pio/build/nanoatmega328/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pio/build/nanoatmega328/FrameworkArduino/HardwareSerial0.cpp.o
Compiling .pio/build/nanoatmega328/FrameworkArduino/HardwareSerial1.cpp.o
Compiling .pio/build/nanoatmega328/FrameworkArduino/HardwareSerial2.cpp.o
*** [.pio/build/nanoatmega328/src/nimcache/stdlib_system.nim.cpp.o] Error 1
Compiling .pio/build/nanoatmega328/FrameworkArduino/HardwareSerial3.cpp.o
With --panics:on -d:useMalloc --os:any --gc:arc gives the same error:
src/nimcache/stdlib_system.nim.cpp:6:10: fatal error: exception: No such file or directory
#include <exception>
^~~~~~~~~~~
compilation terminated.
*** [.pio/build/nanoatmega328/src/nimcache/stdlib_system.nim.cpp.o] Error 1
and same with --panics:on -d:StandaloneHeapSize=1048576 --os:any --gc:arc too:
Compiling .pio/build/nanoatmega328/src/nimcache/stdlib_system.nim.cpp.o
src/nimcache/stdlib_system.nim.cpp:6:10: fatal error: exception: No such file or directory
#include <exception>
^~~~~~~~~~~
compilation terminated.
*** [.pio/build/nanoatmega328/src/nimcache/stdlib_system.nim.cpp.o] Error 1
I tried stable Nim and same, but with the devel version, the error is different:
/home/user/.choosenim/toolchains/nim-#devel/lib/pure/unicode.nim(849, 36) Error: type mismatch: got 'int32' for 'RuneImpl(toLower(ar)) - RuneImpl(toLower(br))' but expected 'int'
src/nimcache/stdlib_system.nim.cpp:6:10: fatal error: exception: No such file or directory > #include <exception>
You could try --exceptions:goto and see if it works better.
I ran into a similar issue yesterday wrapping some C++ code with Nim that re-defined exception in the current namespace.
In your case, it looks like the settings from platformio plugin sets or pulls in --exceptions:cpp. A quick Google search seems to show that at least some Arduino platforms compile using the C++ cflags -fno-exceptions. That would disable C++ exceptions.
I tried --os:ansic instead of --os:standalone, but it gives: command line(1, 2) Error: unknown OS: 'ansic'. Available options are: DOS, Windows, OS2, Linux, MorphOS, SkyOS, Solaris, Irix, NetBSD, FreeBSD, OpenBSD, DragonFly, CROSSOS, AIX, PalmOS, QNX, Amiga, Atari, Netware, MacOS, MacOSX, iOS, Haiku, Android, VxWorks, Genode, JS, NimVM, Standalone, NintendoSwitch, FreeRTOS, Zephyr, Any
and I updated the devel with choosenim but the error persists
I tried with this parameters in devel, but the error is same as above type mismatch, but when I tried the version 1.6.10, the nim was compiled to cpp, but in linking, gave this:
Linking .pio/build/nanoatmega328/firmware.elf
.pio/build/nanoatmega328/src/nimcache/stdlib_digitsutils.nim.cpp.o (symbol from plugin): In function `digits100__stdZprivateZdigitsutils_2':
(.text+0x0): multiple definition of `digits100__stdZprivateZdigitsutils_2'
.pio/build/nanoatmega328/src/nimcache/@m..@s..@s..@s..@[email protected]@[email protected]@slib@sstd@[email protected] (symbol from plugin):(.text+0x0): first defined here
.pio/build/nanoatmega328/src/nimcache/stdlib_digitsutils.nim.cpp.o (symbol from plugin): In function `digits100__stdZprivateZdigitsutils_2':
(.text+0x0): multiple definition of `addInt__stdZprivateZdigitsutils_155(NimStringV2&, unsigned long long)'
.pio/build/nanoatmega328/src/nimcache/@m..@s..@s..@s..@[email protected]@[email protected]@slib@sstd@[email protected] (symbol from plugin):(.text+0x0): first defined here
.pio/build/nanoatmega328/src/nimcache/stdlib_digitsutils.nim.cpp.o (symbol from plugin): In function `digits100__stdZprivateZdigitsutils_2':
(.text+0x0): multiple definition of `addInt__stdZprivateZdigitsutils_158(NimStringV2&, long long)'
.pio/build/nanoatmega328/src/nimcache/@m..@s..@s..@s..@[email protected]@[email protected]@slib@sstd@[email protected] (symbol from plugin):(.text+0x0): first defined here
.pio/build/nanoatmega328/src/nimcache/stdlib_dollars.nim.cpp.o (symbol from plugin): In function `dollar___systemZdollars_3(int)':
(.text+0x0): multiple definition of `dollar___systemZdollars_3(int)'
.pio/build/nanoatmega328/src/nimcache/@m..@s..@s..@s..@[email protected]@[email protected]@slib@[email protected] (symbol from plugin):(.text+0x0): first defined here
.pio/build/nanoatmega328/src/nimcache/stdlib_dollars.nim.cpp.o (symbol from plugin): In function `dollar___systemZdollars_3(int)':
(.text+0x0): multiple definition of `dollar___systemZdollars_6(long long)'
.pio/build/nanoatmega328/src/nimcache/@m..@s..@s..@s..@[email protected]@[email protected]@slib@[email protected] (symbol from plugin):(.text+0x0): first defined here
.pio/build/nanoatmega328/src/nimcache/stdlib_system.nim.cpp.o (symbol from plugin): In function `rawoutput__system_1956(NimStringDesc*)':
(.text+0x0): multiple definition of `raiseRangeErrorNoArgs()'
.pio/build/nanoatmega328/src/nimcache/@m..@s..@s..@s..@[email protected]@[email protected]@[email protected] (symbol from plugin):(.text+0x0): first defined here
.pio/build/nanoatmega328/src/nimcache/stdlib_system.nim.cpp.o (symbol from plugin): In function `rawoutput__system_1956(NimStringDesc*)':
(.text+0x0): multiple definition of `raiseOverflow()'
.pio/build/nanoatmega328/src/nimcache/@m..@s..@s..@s..@[email protected]@[email protected]@[email protected] (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
*** [.pio/build/nanoatmega328/firmware.elf] Error 1
Maybe related:
Try this ?
$ pio run -t clean
$ rm -fr src/nimcache
$ pio run
This is just information.
I've added Serial class to nim-platformio project.
https://github.com/dinau/nimPioArduino/blob/main/src/main.nim
Repository is here,
https://github.com/dinau/nimPioArduino
Compiling:
$ git clone https://github.com/dinau/nimPioArduino
$ cd nimPioArduino
$ pio run