#pragma pass_by_value

C++ only


The #pragma pass_by_value directive specifies how classes containing const or reference members are passed in function arguments. All classes in the compilation unit are affected by this option.


Read syntax diagramSkip visual syntax diagram>>-#--pragma--pass_by_value--(--+-compat--+--)-----------------><


compat Pushes the equivalent of the -qoldpassbyvalue on to the stack.
ansi Pushes the equivalent of the -qnooldpassbyvalue option on to the stack.
default Pushes the compiler default setting for the option -qnooldpassbyvalue on to the stack.
source Pushes the value of the original command line option (-qoldpassbyvalue or -qnooldpassbyvalue) on to the stack.
pop Pops the stack, discarding the current #pragma pass_by_value setting, and restoring the previous #pragma pass_by_value setting on the stack as the option now in effect.
reset Same as pop.


The current setting of #pragma pass_by_value specifies how classes are passed as function arguments in the program source code following the pragma. The setting remains in effect until a subsequent use of the pragma invokes a new setting.

The setting of #pragma pass_by_value overrides the -qoldpassbyvalue compiler option.

If pop or reset is called on an empty stack, the compiler issues a warning message and assumes the -qoldpassbyvalue setting originally set on the command line. If -qoldpassbyvalue was not set on the command line, the compiler will assume the default setting set in the compiler default configuration file.

Use #pragma pass_by_value(compat) to instruct the compiler to mimic the behavior of earlier IBM C/C++ Compilers (v3.6 or earlier) when passing classes as function arguments. Classes containing a const or reference member are not passed by value.

Related information