Arduino-cli #pragma once problem

I have 3 files in my Sketch directory:
Sketch.ino
Foo.h
Bar.h

Sketch.ino contains this:
#include "Foo.h"
void setup() {}
void loop() {}

Foo.h contains this:
#pragma once
#include "Bar.h"

Bar.h contains this:
#pragma once

Till now I used arduino-cli version 0.16.0 for building and everything was ok.
Now I moved to arduino-cli 0.28.0 and the build fails telling me this:

In file included from D:\Home\MyRepos\ChickenHouse\Sketch\Foo.h:2:0,
from D:\Home\MyRepos\ChickenHouse\Sketch\Sketch.ino:1:
D:\Home\MyRepos\ChickenHouse\Sketch\Bar.h:1:1: error: stray '\357' in program
#pragma once
^
D:\Home\MyRepos\ChickenHouse\Sketch\Bar.h:1:2: error: stray '\273' in program
#pragma once
^
D:\Home\MyRepos\ChickenHouse\Sketch\Bar.h:1:3: error: stray '\277' in program
#pragma once
^
D:\Home\MyRepos\ChickenHouse\Sketch\Bar.h:1:4: error: stray '#' in program
#pragma once
^
D:\Home\MyRepos\ChickenHouse\Sketch\Bar.h:1:5: error: 'pragma' does not name a type; did you mean '_Pragma'?
#pragma once
^~~~~~
_Pragma

Does anybody know why the newer version has problem with #pragma once or what's going on?

I think this could be your problem:

That's it! BOM. I completely forgot about this little hidden beast. One of my headers really has the BOM at the beginning. I have no idea how it got there. Now I wonder why the new arduino-cli can't handle it while the old one can. Weird.
Anyway, thank you very much for solving this puzzle.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.