Author Topic: CHANGING HEADER FILE NAME IN MPLAB.  (Read 2269 times)

0 Members and 1 Guest are viewing this topic.

Offline neko efecktzTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
CHANGING HEADER FILE NAME IN MPLAB.
« on: May 22, 2017, 12:30:51 am »
Good morning all.
Just a quick one.
I want to change the name of a header file from lcd.H to lcd_v1.h
I have designed a new PCB with most of the ports changed.
I want to be able to program either of the boards just by changing the #include statement.
It was
#include "lcd.h" but is now
#include "lcd_v1.h"
Why would the compiler be looking for the original header file name of lcd.h???   
     EDIT... even after closing MPLAB and restarting, Also shutting down the computer has no effect.

below is the compile message...

make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/Users/BILL/Documents/MPLAB_PROJECTS/PIC16F877A LCD/PIC16F877A LCD.X'
make  -f nbproject/Makefile-default.mk dist/default/production/PIC16F877A_LCD.X.production.hex
make[2]: *** No rule to make target `lcd.h', needed by `build/default/production/main.p1'.  Stop.
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
make[2]: Entering directory `C:/Users/BILL/Documents/MPLAB_PROJECTS/PIC16F877A LCD/PIC16F877A LCD.X'
make[2]: Leaving directory `C:/Users/BILL/Documents/MPLAB_PROJECTS/PIC16F877A LCD/PIC16F877A LCD.X'
make[1]: Leaving directory `C:/Users/BILL/Documents/MPLAB_PROJECTS/PIC16F877A LCD/PIC16F877A LCD.X'

BUILD FAILED (exit value 2, total time: 865ms)

Thanks
BILL.
« Last Edit: May 22, 2017, 01:20:06 am by neko efecktz »
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: CHANGING HEADER FILE NAME IN MPLAB.
« Reply #1 on: May 22, 2017, 03:10:31 pm »
Are you sure that main.p1 <whatever that is> doesn't contain a reference to lcd.h?  Could lcd.h be included from another included file?

It looks like the toolchain is using a Makefile.  Perhaps the dependencies haven't been updated or the Makefile itself is out of date.
 

Offline neko efecktzTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
Re: CHANGING HEADER FILE NAME IN MPLAB.
« Reply #2 on: May 23, 2017, 01:23:46 am »
I have been through all of the files. 3 of them.
There is no other reference to the original  "lcd.h"
The problem is easily fixed by just leaving the original file name but i am curious.

The reason I want to have a second LCD header file is so I can just select the appropriate header depending on which board I am programming.

thank you
BILL.
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: CHANGING HEADER FILE NAME IN MPLAB.
« Reply #3 on: May 23, 2017, 03:00:18 am »
I dunno what version you are using. I use the old version, without the X.

I am pretty sure I have experienced something potentially similar/same. And I believe it happens whenever:
 
1.file>save as...
2. the window opens, and the name of the original file is at the bottom under "file name:" in blue highlight. Let's say the name of this file is "header file." 
3. But instead of changing the name there to "header file v2," by keyboard, I instead click on another copy I have made of this file which was named "header file v1," as if I want to save over it... but actually I just did it in order to make "header file v1" pop up so I could edit just 1 number, if you know what I mean?

I can't be positive this is related. But this is something I obviously avoid doing, now.

*And no, I don't know how to fix it, after the fact. To this day I have some major projects where I can't change the file name... I assume I could fix it by building a new project, but meh... 

One workaround I happen to prefer anyhow is to use directives to conditionally assemble (I assume works same for compiling; it's been a long time since I compiled any C code):

single universal header file.inc

If headerfile.revision.constant == 0x01

(header file for revision 1)
endif

if headerfile.revision.constant ==0x02

(header file for revision 2)
endif


Then at the top of my main code page, I define these constants.

Constant headerfile.revision.constant = 0x01 ; note to self: valid range 0x01 to 0x02
 
On the surface, this is more work. And it makes the code less legible (in assembly, it's not particularly legible, to begin with) But on to the pro's:
This is especially nice if, say, most of the header file is the same, anyway. And there are only select changes that need to be made. When you edit the header, you have access to all variations in one file. Most importantly, and this is the real key, is that all your "options" (assembly/compiling variants which in my case have included memory defines, code, eeprom initialization, even device type, etc etc in order to cover firmware variations, board revisions, and component changes) are contained in one place within your constant defines in your main code file. Whereas your actual "#include"'s would have to be scattered around to their respective places. And chasing them down would be annoying. You may even forget these options exist unless you say document their existence at the top of your main code page.... which is also where you can simply place these constant defines.
« Last Edit: May 23, 2017, 05:04:04 am by KL27x »
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11630
  • Country: my
  • reassessing directives...
Re: CHANGING HEADER FILE NAME IN MPLAB.
« Reply #4 on: May 23, 2017, 05:53:32 am »
try cleaning all build files first and then recompile.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline neko efecktzTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
Re: CHANGING HEADER FILE NAME IN MPLAB.
« Reply #5 on: May 23, 2017, 08:56:36 am »
I managed to get it to work.
I tried it three times and was able to get it working.
step 1     change   #include "filename"
step 2     run build main project.
                          will get error message.
step 3     rename the header file by right clicking
step 4     run build main project.

step 5     if it works, send me $25.00
 

Offline Luminax

  • Regular Contributor
  • *
  • Posts: 159
  • Country: my
    • Electronesk
Re: CHANGING HEADER FILE NAME IN MPLAB.
« Reply #6 on: May 23, 2017, 09:59:59 am »
I do believe that it is as Mechatrommer said, you need to do the 'clean and build' if you encounter such error.
I think it's the linker just linking all the old object files...
Jack of all trade - Master of some... I hope...
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf