Next Previous Contents

7. #pragmas

The compiler understands some pragmas that may be used to change code generation and other stuff.

7.1 #pragma bssseg (<name>)

This pragma changes the name used for the BSS segment (the BSS segment is used to store uninitialized data). The argument is a string enclosed in double quotes.

Note: The default linker configuration file does only map the standard segments. If you use other segments, you have to create a new linker configuration file.

Beware: The startup code will zero only the default BSS segment. If you use another BSS segment, you have to do that yourself, otherwise uninitialized variables do not have the value zero.

Example:

        #pragma bssseg ("MyBSS")
  

7.2 #pragma codeseg (<name>)

This pragma changes the name used for the CODE segment (the CODE segment is used to store executable code). The argument is a string enclosed in double quotes.

Note: The default linker configuration file does only map the standard segments. If you use other segments, you have to create a new linker configuration file.

Example:

        #pragma bssseg ("MyCODE")
  

7.3 #pragma dataseg (<name>)

This pragma changes the name used for the DATA segment (the DATA segment is used to store initialized data). The argument is a string enclosed in double quotes.

Note: The default linker configuration file does only map the standard segments. If you use other segments, you have to create a new linker configuration file.

Example:

        #pragma bssseg ("MyDATA")
  

7.4 #pragma rodataseg (<name>)

This pragma changes the name used for the RODATA segment (the RODATA segment is used to store readonly data). The argument is a string enclosed in double quotes.

Note: The default linker configuration file does only map the standard segments. If you use other segments, you have to create a new linker configuration file.

Example:

        #pragma bssseg ("MyRODATA")
  

7.5 #pragma regvaraddr (<const int>)

The compiler does not allow to take the address of register variables. The regvaraddr pragma changes this. Taking the address of a register variable is allowed after using this pragma, if the argument is not zero. Using an argument of zero changes back to the default behaviour.

Beware: The C standard does not allow taking the address of a variable declared as register. So your programs become non-portable if you use this pragma. In addition, your program may not work. This is usually the case if a subroutine is called with the address of a register variable, and this subroutine (or a subroutine called from there) uses itself register variables. So be careful with this #pragma.

Example:

        #pragma regvaraddr(1)   /* Allow taking the address
                                 * of register variables
                                 */
  

7.6 #pragma signedchars (<const int>)

Changed the signedness of the default character type. If the argument is not zero, default characters are signed, otherwise characters are unsigned. The compiler default is to make characters unsigned since this creates a lot better code. This default may be overridden by the --signed-chars command line option.

7.7 #pragma staticlocals (<const int>)

Use variables in the bss segment instead of variables on the stack. This pragma changes the default set by the compiler option -Cl. If the argument is not zero, local variables are allocated in the BSS segment, leading to shorter and in most cases faster, but non-reentrant code.

7.8 #pragma zpsym (<name>)

Tell the compiler that the - previously as external declared - symbol with the given name is a zero page symbol (usually from an assembler file). The compiler will create a matching import declaration for the assembler.

Example:

        extern int foo;
        #pragma zpsym ("foo");  /* foo is in the zeropage */
  


Next Previous Contents