#pragma LINK_INFO: Pass Information to the Linker

Scope

Function

Syntax

#pragma LINK_INFO NAME "CONTENT"

Synonym

None

Arguments

NAME: Identifier specific to the purpose of this LINK_INFO.

CONTENT: C-style string containing only printable ASCII characters.

Default

None

Description

This pragma instructs the compiler to put the passed name content pair into the ELF file. For the compiler, the name that is used and its content have no meaning other than each name can contain only one content string. However, multiple pragmas with different NAMEs are legal.

For the Linker or for the Debugger, however, NAME might trigger some special functionality with CONTENT as an argument.

The Linker collects the CONTENT for every NAME from different object files and issues a message if CONTENT differs in different object files.

Note: This pragma only works with the ELF object-file format.
Example

Apart from extended functionality implemented in the Linker or Debugger, this feature can also be used for user-defined link-time consistency checks.

Using the code shown in the following listing in a header file used by all compilation units, the Linker issues a message if the object files built with _DEBUG are linked with object files built without it.

Listing: Using pragmas to assist in debugging


#ifdef _DEBUG
  #pragma LINK_INFO MY_BUILD_ENV DEBUG

#else

  #pragma LINK_INFO MY_BUILD_ENV NO_DEBUG

#endif