duplicate

Date:

01-09-2012

NAME

duplicate, NAME - Provides additional, externally visible names for specified functions. In Fortran, the external name can be a case-sensitive or otherwise unacceptable name.

SYNOPSIS

#pragma _CRI duplicate actual as dupname,...
#pragma _CRI duplicate actual as (dupname,...)
actual

The name of the actual function to which duplicate names will be assigned.

dupname

The duplicate name(s) that will be assigned to the actual function.

!DIR$ NAME (fortran_name="external_name" [, fortran_name="external_name" ] ... )
fortran_name

The name used for the object throughout the Fortran program.

external_name

The external form of the name.

IMPLEMENTATION

Cray Linux Environment (CLE)

DESCRIPTION C/C++

Scope: Global

The duplicate directive lets you provide additional, externally visible names for specified functions.

The actual argument is the name of the actual function to which duplicate names will be assigned. The dupname list contains the duplicate names that will be assigned to the actual function. The dupname list optionally may be parenthesized. The word as must appear as shown between the actual argument and the comma-separated list of dupname arguments.

The duplicate directive can appear anywhere in the source file and it must appear in global scope. The actual name specified on the directive line must be defined somewhere in the source as an externally accessible function. The actual function cannot have a static storage class.

Because duplicate names are simply additional names for functions and are not functions themselves, they cannot be declared or defined anywhere in the compilation unit. To avoid aliasing problems, duplicate names may not be referenced anywhere within the source file, including appearances on other directives. In other words, duplicate names may only be referenced from outside the compilation unit in which they are defined (see Example 2).

DESCRIPTION Fortran

Scope: Global

In a Fortran program, the NAME directive allows you to specify a case-sensitive external name, or a name that contains characters outside of the Fortran character set. The rules for Fortran naming do not apply to the external name string, so any character sequence is valid.

The Fortran standard BIND feature provides some of the capability of the NAME directive.

EXAMPLES

Example 1: duplicate directive in C/C++

#include <complex.h>

extern void maxhits(void);

#pragma _CRI duplicate maxhits as count, quantity     /* OK */

void maxhits(void)
{
   #pragma _CRI duplicate maxhits as tempcount
   /* Error: #pragma _CRI duplicate can't appear in local scope */
}

double _Complex minhits;

#pragma _CRI duplicate minhits as lower_limit
/* Error: minhits is not declared as a function */

extern void derivspeed(void);

#pragma _CRI duplicate derivspeed as accel
/* Error: derivspeed is not defined */

static void endtime(void)
{
}

#pragma _CRI duplicate endtime as limit
/* Error: endtime is defined as a static function */

Example 2: Referencing duplicate names

void converter(void)
{
   structured(void);
}

#pragma _CRI duplicate converter as factor, multiplier /* OK */

void remainder(void)
{
}

#pragma _CRI duplicate remainder as factor, structured
/* Error: factor and structured are referenced in this file */

Example 3: Providing alternate external names for functions

main.c:

extern void fctn(void), FCTN(void);

main()
{
  fctn();
  FCTN();
}

fctn.c:

#include <stdio.h>

void fctn(void)
{
  printf("Hello world\n");
}

#pragma _CRI duplicate fctn as FCTN

Files main.c and fctn.c are compiled and linked using the following command line:

% cc main.c fctn.c

When the executable file a.out is run, the program generates the following output:

Hello world
Hello world

Example 4: NAME directive use in Fortran

The following example shows using the NAME directive when writing calls to C routines.

                     PROGRAM MAIN
!DIR$ NAME (FOO="XyZ")
                     CALL FOO ! XyZ is really being called
                     END PROGRAM

SEE ALSO

intro_directives(7)