12.07.2015 Views

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

C LanguageconstYou can use __attribute__((const)) to specify that a function has no side effects and will notaccess global data. This can help the compiler to optimize code.The following kinds of functions should not be declared __const__:• A function with pointer arguments which examines the data pointed to.• A function that calls a non-const function.exportYou can use __attribute__((export)) to specify that a variable/function has external linkage andshould not be removed. During MIL linking, the compiler treats external definitions at file scope as if theywere declared static. As a result, unused variables/functions will be eliminated, and the alias checkingalgorithm assumes that objects with static storage cannot be referenced from functions outside the currentmodule. During MIL linking not all uses of a variable/function can be known to the compiler. For examplewhen a variable is referenced in an assembly file or a (third-party) library. With the export attribute thecompiler will not per<strong>for</strong>m optimizations that affect the unknown code.int i __attribute__((export)); /* 'i' has external linkage */<strong>for</strong>mat(type,arg_string_index,arg_check_start)You can use __attribute__((<strong>for</strong>mat(type,arg_string_index,arg_check_start))) tospecify that functions take <strong>for</strong>mat strings as arguments and that calls to these functions must betype-checked against a <strong>for</strong>mat string, similar to the way the compiler checks calls to the functions printf,scanf, strftime, and strfmon <strong>for</strong> errors.arg_string_index is a constant integral expression that specifies which argument in the declaration of theuser function is the <strong>for</strong>mat string argument.arg_check_start is a constant integral expression that specifies the first argument to check against the<strong>for</strong>mat string. If there are no arguments to check against the <strong>for</strong>mat string (that is, diagnostics should onlybe per<strong>for</strong>med on the <strong>for</strong>mat string syntax and semantics), arg_check_start should have a value of 0. Forstrftime-style <strong>for</strong>mats, arg_check_start must be 0.Example:int foo(int i, const char *my_<strong>for</strong>mat, ...) __attribute__ ((<strong>for</strong>mat(printf, 2, 3)));The <strong>for</strong>mat string is the second argument of the function foo and the arguments to check start with thethird argument.mallocYou can use __attribute__((malloc)) to improve optimization and error checking by telling thecompiler that:• The return value of a call to such a function points to a memory location or can be a null pointer.11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!