Using GCC __FILE__ Macro to Embed File Name in Code

Recently I have notice a distinct difference with the usage of the...

__FILE__

MACRO between the ESP GCC compiler and the SAMD GCC compiler.

When I use the following code...

// Call to print to serial the File Name + Dat + Time
//
void printVersion(void) {
  Serial.print(F("\n"
                 "Sketch:   " __FILE__ "\n"
                 "Compiled: " __DATE__ " " __TIME__ "\n"
                 "GCC:      " __VERSION__ "\n"
                 "Code Designed & Rewritten by:  \n"));
}

To embed this data within my code, for the ESP version of GCC (V10.3.0),

__FILE__

Will return just the file name, ie;

fileName.ino

But, when ever I use the same code and compile for an SAMD M0 device (only tested with Seeed XIAO SAMD device thus far),

__FILE__

will return the full path, including the file name.
I am currently using IDE;

Version: 2.2.1
Date: 2023-08-31T14:35:44.802Z
CLI Version: 0.34.0

Currently installed: esp8266 by ESP8266 Community, V3.1.2
and
Xiao SAMD: Seeed SAMD Boards, V1.8.5.

All files and libraries are up to date.

Any ideas?

I have moved your topic to Programming Questions.... I couldn't discern this as a specific issue with IDE 2.x.

It may depend on a compiler option - see compiler documentation and how to change the settings.

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