lpcware

__FILE__ macro long vs short name

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by fancypants on Mon Oct 20 11:33:22 MST 2014
Hi

I've run into an issue where I'm getting two different sized binary output files for the same code, in two different projects using the "same" settings, causing one of the builds to overflow the flash memory space (and the associated linker issues).

Issue: when building files with asserts, the __FILE__ macro in one of the builds is expanding to a short (i.e. relative) path/filename whereas the other project is expanding to a long (i.e. absolute) path/filename. The long path/filename is overflowing the flash memory space when linked.

Details: I've got an existing project that I've been developing for a while - has upgraded through many versions of LPCXpresso. The settings/builds have been tailored and got everything working as I expect. We're now going to get everything checked into git (using egit) so I figured I'd work everything out by creating new test workspaces/projects, copying/importing the code, configure all the settings, and getting the builds to work as I expect before checking everything into the official git repo. The projects are managed makefiles (created projects with "LPCXpresso C Project"). I finally tracked down why the DEBUG build sizes weren't what I expected: the __FILE__ macro is expanded using a relative (short) path in my original project, and an absolute (long) path in the new project. The root of the issue appears to be in the subdir.mk makefile. The original project's make rule is "src/%.o: ../src/%.c" and the new project's rule is "src/main.c: /Users/........../main.c" (with a unique rule for each source file). When the make autovar $< is expanded in the recipe it is short for the original project's rule, and long for the new project's rule. This results in different lengths of __FILE__. I've looked through the settings for how to make LPCXpresso change the path used in the makefiles but I haven't been successful. Is there a way to do this?

I'm using LPCXpresso v7.4.0 on OSX 10.9 for reference.

Thanks
-Kevin

Outcomes