This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Renaming Header File Error

When renaming a header file within the CCS IDE, the new header file name is automatically updated throughout the all project. The IDE also updates the new name at all the c files that has #include on that header file. BUT, when it updates the #include to the new name it moves the #inlcude line to the top of the file. This later causes compile cerrors if the order of including was important.

For example, i was using the TivaWare usb_dev_msc example and renamed usb_msc_structs.c/usb_msc_structs.h to usb_msc_sd_structs.c/usb_msc_sd_structs.h.

The list of includes in the original usb_msc_structs.c file is:

#include <stdint.h>

#include <stdbool.h>

#include "driverlib/usb.h"

#include "usblib/usblib.h"

#include "usblib/usb-ids.h"

#include "usblib/device/usbdevice.h"

#include "usblib/device/usbdmsc.h"

#include "usb_msc_structs.h"

#include "usbdsdcard.h"

this is changed after the renaming to:

#include "usb_msc_sd_structs.h"

#include <stdint.h>

#include <stdbool.h>

#include "driverlib/usb.h"

#include "usblib/usblib.h"

#include "usblib/usb-ids.h"

#include "usblib/device/usbdevice.h"

#include "usblib/device/usbdmsc.h"

#include "usbdsdcard.h"

When compiling the project with this new order of include list, usb_msc_sd_struct.h gets compile error because it uses definitions found in file usbdmsc.h which is now included later.

Note: i also noticed that this happens only if you change the c file name first. if you change the h file name first and then the c file name the new name is updated correctly without moving the #include line to the top of the file.

I am using CCS Version: 6.1.1.00022.

Thanks,

Timor

  • Hi Timor,
    Just to confirm, are you using the editor 'refactor->rename' functionality?

    Thanks
    ki
  • I am selecting the file in the CCS project explorer and then I right-click the mouse to open the context menu and there I select "rename" (or I am pressing F2).

    Timor

  • Timor Lansky said:
    When compiling the project with this new order of include list, usb_msc_sd_struct.h gets compile error because it uses definitions found in file usbdmsc.h which is now included later.

    I found this possibly related Eclipse thread https://www.eclipse.org/forums/index.php/t/1068853/ which suggests the issue might be in the underlying Eclipse rather than CCS specific functionality.

    A suggested "work-around" is to rename files / folders outside of Eclipse, and then refresh the project in Eclipse. Any #include filenames / include file guards would then have to be renamed manually, but that should prevent the Eclipse refactoring from making unwanted changes.