macro __FILE__ has been changed

In various situations it might be useful to have means to find out which sketch was uploaded to an Arduino (especially if you own more than one). On March 1st, in ShapeShifter showed the usage of the pre-defined macro FILE giving the file name of the sketch. When I updated to 1.6.6 recently, I was surprised to see the macro now returns the complete path name preceding the file name which is not what I wanted. It is easy to strip the file name using the String class but for some reasons I usually try to avoid the usage of this class. Collecting all my knowledge about addresses and pointers I managed to extract the file name but surely it can be done more efficiently.

void setup() {
  char s[] = __FILE__;
  byte b = sizeof(s);
  while ( (b > 0) && (s[b] != '\\')) b--;
  char *u = &s[++b];

void loop() {
  // put your main code here, to run repeatedly:


Although it's indeed solution and it's a good thing not to use String class but it still sucks they changed it. This way you trow away quite some memory... Because, although you only print the filename, you save the whole damn path in memory :s I hope they change this back and use a proper named macro for the path like PATH

Because, although you only print the filename, you save the whole damn path in memory

But only while setup() is running.

OP: Take a look at the strstr() function, or the strtok() function.

Yeay, only in setup it's in RAM. But the rest of the time it's still in ROM and I think that's a wast as well!

FILE won't have changed, its simply the filename passed to the compiler, the framework calling the compiler will have changed. It may even be configurable.

I don’t care if it’s the framework or the compiler. They’re combined to be the Arduino IDE so the outcome changed with an upgrade of that.