-qalloca, -ma

Category

Object code control

Pragma equivalent

#pragma alloca

Purpose

Provides an inline definition of system function alloca when it is called from source code that does not include the alloca.h header.

The function void* alloca(size_t size) dynamically allocates memory, similarly to the standard library function malloc. The compiler automatically substitutes calls to the system alloca function with an inline built-in function __alloca in any of the following cases:
  • You include the header file alloca.h
  • You compile with -Dalloca=__alloca
  • You directly call the built-in function using the form __alloca
The -qalloca and -ma options and #pragma alloca directive provide the same functionality if any of the above methods are not used.

Syntax

Read syntax diagramSkip visual syntax diagram
Option syntax

>>-+- -q--alloca-+---------------------------------------------><
   '- -ma--------'   

Read syntax diagramSkip visual syntax diagram
Pragma syntax

>>-#--pragma--alloca-------------------------------------------><

Defaults

Not applicable.

Usage

If you do not use any of the above-mentioned methods to ensure that calls to alloca are replaced with __alloca, alloca is treated as a user-defined identifier rather than as a built-in function.

Once specified, #pragma alloca applies to the rest of the file and cannot be disabled. If a source file contains any functions that you want compiled without #pragma alloca, place these functions in a different file.

You may want to consider using a C99 variable length array in place of alloca.

Predefined macros

None.

Examples

To compile myprogram.c so that calls to the function alloca are treated as inline, enter:

xlc myprogram.c -qalloca

Related information