Sun Studio 12: C++ User's Guide

B.1.1 Overloaded Functions as Pragma Arguments

Several pragmas listed in this appendix take function names as arguments. In the event that the function is overloaded, the pragma uses the function declaration immediately preceding the pragma as its argument. Consider the following example:


int bar(int);
int foo(int);
int foo(double);
#pragma does_not_read_global_data(foo, bar)

In this example, foo means foo(double), the declaration of foo immediately preceding the pragma, and bar means bar(int), the only declared bar. Now, consider this following example in which foo is again overloaded:


int foo(int);
int foo(double);
int bar(int);
#pragma does_not_read_global_data(foo, bar)

In this example, bar means bar(int), the only declared bar.However, the pragma will not know which version of foo to use. To correct this problem, you must place the pragma immediately following the definition of foo that you want the pragma to use.

The following pragmas use the selection method described in this section: