#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 used name and its content have no meaning, other than one NAME can only contain one content. However, multiple pragmas with different NAMEs are legal.

For the linker or the debugger however, the NAME might trigger some special functionality with CONTENT as an argument.

The linker collects the CONTENT for every NAME in different object files and issues a message if a different CONTENT is given for 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 following listing code in a header file used by all compilation units, the linker will issue 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