none
Compilation of header files... What is really going on? RRS feed

  • Question

  • Hello,

    I really hope someone can give some heads up on this... Bare in mind I am using a third party compiler for PIC32 but the question may apply to all compilers in general... at least I hope so.

    This is not a programming question. It is simply a computer/compiler question related to knowing exactly what goes on when a compiler compiles its files after they have been altered by an external application and not the compiler GUI.

    HERE'S WHAT I AM DOING:

    The logic in my PIC32 controller is dependent on a command string in a header file called "User.h". The command string could look like something like this:

    // ================ User.h

    char volatile ProgString_[] = "     \
    1                                     [C1_SLOT5]_[BT3]               _DCT_           [C1_SLOT3]_[BT1]                                                        [OR:IPP]_[OL_PosPulse]                   \
    1                                     [(0)]                                          [C1_SLOT1]_[BY1]                                                        [OR:SCV]_[OL_(3)]                        \
    1                                     [C1_SLOT5]_[BT1]                               [C1_SLOT8]_[BT1]                                                                                                 \
    1                                     [C1_SLOT2]_[BT1]                                                                                                                                                \
    ~                                                                                                                                                                                                     \
    2                                     [C1_SLOT5]_[BT4]               _UCT_           [C1_SLOT3]_[BT2]                                                        [OR:IPP]_[OL_PosPulse]                   \
    2                                     [(5)]                                          [ML_<2>]                                                                [OR:SCV]_[OL_(0)]                        \
    2                                     [C1_SLOT5]_[BT2]                               [ML_<3>]                                                                                                         \
    2                                     [C1_SLOT2]_[BT1]                                                                                                                                                \
    ~                                                                                                                                                                                                     \
    3                                     [C1_SLOT2]_[BT1]               _INV_           [C1_SLOT3]_[BT4]                                                                                                 \
    **     \
    ";

    //=========================================

    Whatever that means in the string above is not important, just so you know that its a string that exists in the header file called User.h.

    Therefore, My program in my PIC32 microcomputer fetches information stored in the command string defined in the above header file and decodes it into a series of commands in order to carry out a particular logic sequence.

    **********************************************************************

    OKAY, So in laymen's terms so far, we have a C program in a micro computer called PIC32 which is made up of with several .c files and several .h files AND one .h file called User.h. In the User.h file we have a long string where -ONLY ONE- .c file will refer to it. 

    ********************************************************************** 

    So therefore, if the command string in the User.h file is empty, then the PIC32 does nothing! In other words the logical functionality that the PIC32 is to carry out is all stored in that special command string in the User.h file.

    Having said this, with a program designed in Excel using VBA there is certain GUI selections that can be made by the user. Still in Excel VBA, based on those selections the user made in via the Excel GUI, I fill out a text file with the respective code commands in a string and then save this file as User.h. Still in Excel VBA, I then copy this User.h file into the PIC32 project directory (Where my PIC32 program resides) consequentially deleting and replacing  the old User.h file.

    Then, if I go into my PIC32 compiler software and compile my program. The PIC32 compiler sees the new User.h file and complies it along with its new command string. Then I download it to the PIC32 and the program obviously fetches the command string stored in the new User.h file and does its logic accordingly.

    --BUT--

    I have another way of compiling and downloading the program to the PIC32 after the user finished with his Excel GUI selections and that is by using DOS command lines issued by the Excel application. This allows the user to not have to leave Excel application and go in a compiler and compile/download in the traditional manner. In other words he can do this all by staying in the Excel app.

    The problem is that when I compile & program the PIC32 part using the DOS command lines (NOT using the PIC32 compiler GUI) the program runs according to the old User.h command string instead of the new one. Its like the new User.h file that replaced the old one isn't seen at compile time when using the DOS command lines???  It still keeps the information of the old User.h file WHICH I DELETED!!!!

    How can this be???

    For the PIC32 to actually see the new User.h file along with its new command string, I MUST go into the compiler and recompile and download...  BUMMER!

    **************************************************

    In summary, what I am trying to explain here is that if we have a header file called User.h, can we alter its contents using an external program and then save it under the same name under the same project directory, and then use DOS command lines to compile the program in assumption that what ever we changed in the User.h file would be recompiled accordingly?

    **************************************************

    Here's the command line I am using... don't know if this is familiar to you guys though? let me know?

    "C:\Users\Public\Documents\Mikroelektronika\mikroC PRO for PIC32\mikroCPIC32.exe" -Y -RA -L -MSF -DBG -pP32MX795F512L -HEAP 5000 -UICD -DL -SSA -EBASE 0x9FC01000 -INTDEF MV_SRS7_IS32 -O11111114 -fo80 -N"C:\_PIC32_PROGRAMMING\IMB_164\MAIN.mcp32" -SP"C:\Users\Public\Documents\Mikroelektronika\mikroC PRO for PIC32\Defs\" -SP"C:\Users\Public\Documents\Mikroelektronika\mikroC PRO for PIC32\Uses\" -SP"C:\_PIC32_PROGRAMMING\IMB_164\" -IP"C:\_PIC32_PROGRAMMING\IMB_164\" "MAIN.c" "API.c" "Serial_Flash_driver.c" "COMMON.c" "BUF.c" "C88B.c" "C88i.c" "C88.c" "UPC.c" "_BUF.c" "BFM.c" "FPV.c" "SUP.c" "_AND.c" "_OR.c" "_XOR.c" "_RED.c" "_FED.c" "_INV.c" "_BS.c" "_BC.c" "_UCT.c" "__Lib_CP0.emcl" "__Lib_Math.emcl" "__Lib_MathDouble.emcl" "__Lib_System.emcl" "__Lib_SoftResetDma.emcl" "__Lib_Delays.emcl" "__Lib_CType.emcl" "__Lib_CString.emcl" "__Lib_CStdlib.emcl" "__Lib_CMath.emcl" "__Lib_MemManager.emcl" "__Lib_Conversions.emcl" "__Lib_I2C_12345.emcl" "__Lib_SPI_1234.emcl" 
    "C:\Users\Public\Documents\Mikroelektronika\mikroProg Suite For PIC\mikroProg Suite for PIC.exe" -w -fC"C:\_PIC32_PROGRAMMING\IMB_164\MAIN.hex" -pPIC32MX795F512L -q

    Any help greatly appreciated.... sorry if this thread is off topic.... I am really need some help!

    r

    Saturday, March 5, 2016 12:54 AM

Answers

  • thanks guys .... I think I solved it .... works so far. A few things that may relate to the compiler.... a) The command line came from copying the first message of the build which contained all the necessary commands b) Some issue with the compiler IDE copying incomplete commands c) Before leaving the compiler you must make sure you make a release build Thanks all for replying very appreciated!
    Saturday, March 5, 2016 7:12 PM

All replies

  • Perhaps there are environment variables that affect compilation?
    Perhaps include paths are different?
    If it is not getting user.h from where you think it is then it is getting it from somewhere else.  Look for other copies stored elsewhere on your drive.
    Saturday, March 5, 2016 4:14 AM
  • Hello,

    I think it's case of programmer's implementation. In one situation you don't have  choice to select another .h file, it's implement statically in code so you compile with everytime same interface. In another situation programmer implement system of choice for different files (but must have right inside structure) for compile options. Yes, answer acn be also another location of .h files but this is in my opinion not so frequent. Simply try find that file name on computer, if it's located on another place. If no and you delete that .h file for example, and therefore system can work, probably structure is implemented inside program. Yes, also all depends about number of needed files and size.

    Regards...

    Duris_I


    • Edited by Duris_I Saturday, March 5, 2016 8:13 AM
    Saturday, March 5, 2016 7:29 AM
  • I really hope someone can give some heads up on this... Bare in mind I am using a third party compiler for PIC32 but the question may apply to all compilers in general... at least I hope so.

    What you are saying seems the opposite of what one might expect.

    The DOS command line compile has no knowledge of which files have changed, so it should use the current version of your header file user.h.

    Your GUI (IDE) probably does have an understanding of which files have changed, and if you change user.h outside the GUI it might fail to pick up the change.

    Like Wyck I am wondering if the paths are messed up, and you are not including the file you think you are.

    Where is this file user.h? Is it in the same directory with the .c files that you are compiling? And what does the include statement look like? Is it just

    #include "user.h"

    ?

    Another idea. Are you absolutely sure that your Excel program is changing the file? If you open it in a text editor, is the change there? If not, perhaps the Excel application does not have write permission in the target directory?

    And where is the executable being written to? Presumably it should be overwriting the original. Are you sure this is happening (check the time stamp of the file). If not, maybe Excel is writing the executable to the wrong place, or does not have write permission in the correct place.

    And what about the working directory? Your DOS command line seems to be assuming that the working directory is the source directory where the .c files are located. I don't know about your IDE, but the Visual C++ IDE assumes that the working directory is the project directory, which may not be the same as the source directory.


    David Wilkinson | Visual C++ MVP

    Saturday, March 5, 2016 12:06 PM
  • thanks guys .... I think I solved it .... works so far. A few things that may relate to the compiler.... a) The command line came from copying the first message of the build which contained all the necessary commands b) Some issue with the compiler IDE copying incomplete commands c) Before leaving the compiler you must make sure you make a release build Thanks all for replying very appreciated!
    Saturday, March 5, 2016 7:12 PM
  • Please mark the thread answered.
    Sunday, March 6, 2016 7:54 AM