This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARMASM - include file using defined parameter

Hello,

I trying to include .s file into another .s file using INCLUDE directive with defined parameter, but without success. 

I check 2 scenario.

Scenario 1

startup.s file:

#include "Configuration.h"
	
#if defined (CONF_CHIP_ID_LPC1549JBD64)
	INCLUDE CONF_ARMHAL_STARTUPSFILE

... ; some asm code #endif
END

And "Configuration.h" file:

#define CONF_CHIP_ID_LPC1549JBD64    1
#define CONF_ARMHAL_STARTUPSFILE "..\..\..\ARM_HAL\startup_LPC15xx.s"

After compile I give an error:

.....\startup.s(17): error: A1023E: File ""..\..\..\ARM_HAL\startup_LPC15xx.s"" could not be opened: No such file or directory

- Please look at double quote at filename!

Scenario 2

In "Configuration.h" file, I was changed value of CONF_ARMHAL_STARTUPSFILE parameter, to without quote :

#define CONF_CHIP_ID_LPC1549JBD64    1
#define CONF_ARMHAL_STARTUPSFILE ..\..\..\ARM_HAL\startup_LPC15xx.s

After compile I give an error:

....\startup.s(17): error: A1023E: File ". .\. .\. .\ARM_HAL\startup_LPC15xx . s" could not be opened: No such file or directory

- Please look at additional spaces in filename!

Please, what's wrong in C preprocessor? Is any way how to include file, defined by #define parameter?

Thank you.

This code is part of C project written in uVision IDE. Parameter "--cpreproc" is used for assembler.

ARMCC c5.06 update 5

ARMASM v5.06 update 5

Parents
  • Hi,

    Thank you for posting about the issue you are facing, and including an example to reproduce it.

    In Configuration.h, you have the following statement in Scenario 1:

    #define CONF_ARMHAL_STARTUPSFILE     "..\..\..\ARM_HAL\startup_LPC15xx.s"
    

    As per the documentation for the INCLUDE directive, you shouldn’t have double quotes around the file name. Therefore, you correctly changed it to the following line in Scenario 2:

    #define CONF_ARMHAL_STARTUPSFILE     ..\..\..\ARM_HAL\startup_LPC15xx.s
    

    In this case, the C preprocessor will correctly add spaces around the . character as it is not within double quotes. To avoid this issue, you can use one of the following workarounds:

    • Insert the whitespace removal character sequence ## around each of the . characters in the path to the file. For example:
      .##.##\##.##.##\ARM_HAL\startup_LPC15xx##.##s
      
    • Alternatively, remove the relative path from the #define statement, add the whitespace removal character sequence ## around the remaining . character in the file name, and add the file include path to the armasm command-line option. For example, change the #define to:
      #define CONF_ARMHAL_STARTUPSFILE     startup_LPC15xx##.##s
      
      and use the following armasm command:
      armasm --cpreproc --cpu=Cortex-M4 -i "..\..\ARM_HAL" startup.s -o startup.o
      

    This should enable you to proceed building your project.

Reply
  • Hi,

    Thank you for posting about the issue you are facing, and including an example to reproduce it.

    In Configuration.h, you have the following statement in Scenario 1:

    #define CONF_ARMHAL_STARTUPSFILE     "..\..\..\ARM_HAL\startup_LPC15xx.s"
    

    As per the documentation for the INCLUDE directive, you shouldn’t have double quotes around the file name. Therefore, you correctly changed it to the following line in Scenario 2:

    #define CONF_ARMHAL_STARTUPSFILE     ..\..\..\ARM_HAL\startup_LPC15xx.s
    

    In this case, the C preprocessor will correctly add spaces around the . character as it is not within double quotes. To avoid this issue, you can use one of the following workarounds:

    • Insert the whitespace removal character sequence ## around each of the . characters in the path to the file. For example:
      .##.##\##.##.##\ARM_HAL\startup_LPC15xx##.##s
      
    • Alternatively, remove the relative path from the #define statement, add the whitespace removal character sequence ## around the remaining . character in the file name, and add the file include path to the armasm command-line option. For example, change the #define to:
      #define CONF_ARMHAL_STARTUPSFILE     startup_LPC15xx##.##s
      
      and use the following armasm command:
      armasm --cpreproc --cpu=Cortex-M4 -i "..\..\ARM_HAL" startup.s -o startup.o
      

    This should enable you to proceed building your project.

Children