As far as I know, there’s no requirement that the main entrypoint of your program be called main.cpp
… however, it’s more of a convention that file containing that main entrypoint… main()
… is called main.cpp
just so you can find it. Arduino do it differently… they require the main sketch file to have the same name as the folder containing it. But there is unfortunately nothing requiring either the __FILE__
or __BASE_FILE__
macros to contain absolute paths…
The Microsoft C++ compiler has a flag that lets you change the behaviour between relative and absolute paths… but I don’t anything similar for the GNU C++ compiler. -fmacro-prefix-map=old=new
is the nearest I get, but it seems that you’re have to hard-code the path… just like if you used the #line
directive in the source file to set the name/line number.