Skip to content

The macro __FILE__ does changed? #6491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mikekgr opened this issue Sep 7, 2019 · 7 comments
Closed

The macro __FILE__ does changed? #6491

mikekgr opened this issue Sep 7, 2019 · 7 comments

Comments

@mikekgr
Copy link

mikekgr commented Sep 7, 2019

Dear Sirs,
I am using Arduino 1.8.8 at Windows OS having ESP8266 core Git master updated.
I notice that recently the macro FILE does not include the full path + the filename. That was the case recently. Now the command:
Serial.printf(" Source File Name: %s\n",FILE);
gives: Source File Name: testSketch.ino
before was: Source File Name: C:\ArduinoIDE\sketchbook\testSketch\testSketch.ino
Do you know if this is an error or change in core plans?
Can I revert back the FILE macro contains the full path as well as the filename?
Thanks and Best Regaards
Mike Kranidis

@d-a-v
Copy link
Collaborator

d-a-v commented Sep 7, 2019

It's a feature (a "change in core plans") !
It is also a step towards reproducible generation of flash binaries,
it also offers smaller flash occupation with debug messages,
privacy for pre-generated core libraries,

What is your use case ?

@mikekgr
Copy link
Author

mikekgr commented Sep 7, 2019

Thanks for the fast answer.
My use case is to know exactly from were my source file coming from. Because I have same naming in Arduino Projects but in different locations ex external USB disks vs internal. Is there anything I can do in order to have the previous behavior?
Thanks and Best Regards,
Mike Kranidis

@d-a-v
Copy link
Collaborator

d-a-v commented Sep 7, 2019

This feature has been awaited for a long time
(try to google for gcc __FILE__ full path, check also #4520).
Thanks to @earlephilhower who did this job by patching gcc.

Is there anything I can do in order to have the previous behavior?

I'd use a personal git repository to handle everything: versioning, backuping, sharing common code between two closely-looking source code and a string to differentiate them, ...

@mikekgr
Copy link
Author

mikekgr commented Sep 7, 2019

@d-a-v Dear Sir, I totally understand the need to patch the gcc in order to strip out the path part of the filename.
I understand your suggestion regarding the personal git, I have it already. This change is not convenient to me but it is not a big deal.
Thanks a lot for the answer and the suggestion.

Best Regards,
Mike Kranidis

@earlephilhower
Copy link
Collaborator

Looks like this has been settled. Closing.

@WeaVaer
Copy link

WeaVaer commented Dec 1, 2020

I wish this entry had not been closed with assumption of settlement.

Well,
provided __FILE__ macro has changed stripping path info for the aforementioned reasons,
the need to have a macro giving full path to the source code still persists for various previously mentioned reasons here or in other blog entries for different people. I humbly am among them.
Something named like __PATH__ maybe could be very useful in our situation..
Since the stripping have been done effortlessly with expertise in the __FILE__ macro,
it shouldn't be too difficult to provide a macro which gives us the path.

Or a macro that gives full path + filename just like before).

Or provide another method to get the full path of compiled source code into the sketch to be utilized during runtime.

We need at least one of this proposed solutions to come true.

@WeaVaer
Copy link

WeaVaer commented Dec 1, 2020

@earlephilhower
Could you please point out exactly where in source you applied the gcc patch,
so I can revert it back to standard as it was back in older versions of the core ?
I need filenames and line numbers or a diff file if you prefer.

This task is crucial for me to sustain a few distributed products which does not work anymore because of this change since it was highly dependent on __FILE__ having full path.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants