Compiling Teensy Sketches with VisualCode (Win10)

Thanks for testing. Added it to v1.2.0 which I just released: https://github.com/luni64/VisualTeensy/releases

Release notes:

Bugfixes
  • fixed bug with setting the RTC time for T3.x boards on special PC configurations
  • changed object file name scheme to allow source files with same base name but different extension (e.g. foo.c and foo.cpp)
  • fixed bugs in 'File | New' and 'File | Save As'

New features
Until now VisualTeensy was able to either copy or link the Teensyduino core files to the project folder. The source typically was an existing Arduino installation. This version additionally allows to directly 'git clone' the repository (https://github.com/PaulStoffregen/cores) into the project folder.

Besides removing the dependency on an existing Arduino installation, cloning the Teensyduino core is very convenient for testing new Teensyduino versions or to experiment with the currently worked on version. You can use the native git tools of vsCode or any other git tool to check out all versions experimental pull requests or the current repository master with a few clicks.
 
Problems compiling QNEthernet were reported here: https://forum.pjrc.com/threads/6806...for-Teensy-4-1?p=289276&viewfull=1#post289276

The reason for the issue is that VisualTeensy adds all subdirectories of the <lib>/src folder to the include search path. QNEthernet has a copy of the errno.h header in one of its subdirectories.
Since GCC includes all include folders specified with -Ipath into the search path BEFORE the system files, the core includes the QNEthernet version of errno.h which causes the issue.

I therefore restricted the include search path for libraries to
  • <lib>/
  • <lib>/utility
  • <lib>/src

This works for the reported problem. I also think that this complies to the library specification given here https://arduino.github.io/arduino-cli/0.19/library-specification/. However, it will generate problems for libraries assuming subfolders are included in the search path. I therefore want to publish the changes only after some testing.

If someone is interested, the beta version can be downloaded here: https://github.com/luni64/VisualTeensy/issues/58
 
Problems compiling QNEthernet were reported here: https://forum.pjrc.com/threads/6806...for-Teensy-4-1?p=289276&viewfull=1#post289276

The reason for the issue is that VisualTeensy adds all subdirectories of the <lib>/src folder to the include search path. QNEthernet has a copy of the errno.h header in one of its subdirectories.
Since GCC includes all include folders specified with -Ipath into the search path BEFORE the system files, the core includes the QNEthernet version of errno.h which causes the issue.

I therefore restricted the include search path for libraries to
  • <lib>/
  • <lib>/utility
  • <lib>/src

This works for the reported problem. I also think that this complies to the library specification given here https://arduino.github.io/arduino-cli/0.19/library-specification/. However, it will generate problems for libraries assuming subfolders are included in the search path. I therefore want to publish the changes only after some testing.

If someone is interested, the beta version can be downloaded here: https://github.com/luni64/VisualTeensy/issues/58

Luni,

Thanks for the quick response. I tried v1.2.1 beta and it still has the issue.

Steps to repeat

1. Visual teensy, create new project in empty folder
2. Add QNEthernet library
3. Save
4. Visual Studio opens
5. Clean
6. Build

Code:
CORE [ASM] memset.S 
CORE [ASM] memcpy-armv7m.S 
CORE [CC]  sm_free.c 
cores\teensy4/sm_free.c: In function 'sm_free_pool':
cores\teensy4/sm_free.c:15:3: error: 'errno' undeclared (first use in 
this function)
   errno = EINVAL;
   ^
cores\teensy4/sm_free.c:15:3: note: each undeclared identifier is reported only once for each function it appears in
cores\teensy4/sm_free.c:15:11: error: 'EINVAL' undeclared (first use in this function)
   errno = EINVAL;
           ^
make: *** [makefile:182: .vsteensy/build/core/sm_free.c.o] Error 1
make: *** Waiting for unfinished jobs....
CORE [CC]  sm_util.c 
CORE [CC]  sm_calloc.c 
CORE [CC]  clockspeed.c 
CORE [CC]  usb_serial.c 
CORE [CC]  usb_keyboard.c 
CORE [CC]  sm_szalloc.c 
cores\teensy4/sm_szalloc.c: In function 'sm_szalloc_pool':
cores\teensy4/sm_szalloc.c:14:3: error: 'errno' undeclared (first use 
in this function)
   errno = EINVAL;
   ^
cores\teensy4/sm_szalloc.c:14:3: note: each undeclared identifier is reported only once for each function it appears in
cores\teensy4/sm_szalloc.c:14:11: error: 'EINVAL' undeclared (first use in this function)
   errno = EINVAL;
           ^
make: *** [makefile:183: .vsteensy/build/core/sm_szalloc.c.o] Error 1
CORE [CC]  sm_malloc.c 
cores\teensy4/sm_malloc.c: In function 'sm_malloc_pool':
cores\teensy4/sm_malloc.c:17:3: error: 'errno' undeclared (first use in this function)
   errno = EINVAL;
   ^
cores\teensy4/sm_malloc.c:17:3: note: each undeclared identifier is reported only once for each function it appears in
cores\teensy4/sm_malloc.c:17:11: error: 'EINVAL' undeclared (first use in this function)
   errno = EINVAL;
           ^
cores\teensy4/sm_malloc.c:101:10: error: 'ENOMEM' undeclared (first use in this function)
  errno = ENOMEM;
          ^
make: *** [makefile:183: .vsteensy/build/core/sm_malloc.c.o] Error 1  
CORE [CC]  usb.c 
CORE [CC]  analog.c 
CORE [CC]  usb_seremu.c 
CORE [CC]  usb_joystick.c 
CORE [CC]  interrupt.c 
CORE [CC]  delay.c 
CORE [CC]  sm_zalloc.c 
The terminal process "C:\Program Files\PowerShell\7\pwsh.exe -Command .../GitHub/VisualTeensy_v1_2_1.beta/make.exe all -j -Otarget" terminated with exit code: 1.
 
Did you add the QNEthernet library to your lib folder or to the shared library folder?

Edit:
You probably did, I can reproduce that when including the lib from the shared libraries repository

Can you try to comment or delete line 143 from the makefile and see if it works then?
This one:
Code:
143  #INCLUDE         += $(foreach d, $(LIB_DIRS_SHARED), -I$d)
 
Last edited:
Did you add the QNEthernet library to your lib folder or to the shared library folder?

Edit:
You probably did, I can reproduce that when including the lib from the shared libraries repository

Can you try to comment or delete line 143 from the makefile and see if it works then?
This one:
Code:
143  #INCLUDE         += $(foreach d, $(LIB_DIRS_SHARED), -I$d)

Yes, shared library folder.

The comment in makefile worked, I can compile the blinky. I'll try my full application next and let you know.

Thank you Luni.

EDIT: My application compiles now and looks to be working. Thanks again.
 
Hello Lutz,

today I apply the last update to VScode and since I cannot build/upload any project to teensy. Seem like something is broken :-(
I tried to clean all preferences, apply VisualTeensy again to reset anything, but still no luck.
This is the message I get from VScode :

Code:
Jeton « all » inattendu dans une expression ou une instruction.
Au niveau de ligne : 1 Caractère : 46
+ 'C:/Program Files/Visual Teensy/make.exe' all <<<<  -j -Otarget
    + CategoryInfo          : ParserError: (all:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

Do you have a such behaviour by your side ?
Thank you,
Manu
 
I upgraded to the latest vsCode version 1.640 and use the latest VisualTeensy v1.50. Every things works as it always did. Unfortunately I don't speak french. Can you translate the first two lines in the error message?
 
I upgraded to the latest vsCode version 1.640 and use the latest VisualTeensy v1.50. Every things works as it always did. Unfortunately I don't speak french. Can you translate the first two lines in the error message?
Google Translate gives
Unexpected "all" token in an expression or statement.
At line level: 1 Character: 46
 
Thanks, could have thought of google translate myself .. :-/

I can reproduce your behavior, looks like the new vsCode version chokes on executing commands when the path has spaces in it. I can't do much from the vsTeensy side. Simplest would be to install vsTeensy to some path without spaces. Or wait until it gets fixed, I assume that this will break a lot of task setups...
 
Thank for inquiring about this.
Putting "VisualTeensy" repertory at the top of HDD, without space solve the problem.
Hope that MS fix this bug ASAP since I have a lot of projects and don't want to fix them all.

Thanks
 
I tried to output the short 8.3 path (e.g. C:/TOOLCH~1/NEUERO~1/make.exe) which works with the current vsCode version. However, you'd still have to convert the existing projects so, that won't help you much I assume.
 
I'm sure it's better to wait for MS to fix this new behaviour as I guess that many will have problems with it.
 
Hello Luni,

I'm sorry to come back about this, but I'd like you to release your version of visual teensy that use short 8.3 path since microsoft seem to not have intention to go back about this new behaviour of VisualCode.
I prefer to update my projects files rather than change all my paths on my HDD.

Thank you,
Manu
 
I upgraded vsCode to version 1.64.2 and spaces in tasks paths work again. So seems to be fixed?

vsCode v1.642
Powershell v7.1.3

Which versions do you use?

Code:
 "tasks": [
    {
      "label": "Build",
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "command": "C:/Program Files/Visual Teensy/make.exe",
      "args": [
        "all",
        "-j",
        "-Otarget"
      ]
    },
....


Edit: Seems to be this issue https://github.com/microsoft/vscode/issues/142196 which was fixed with 1.642
 
Last edited:
Back
Top