[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


Pragma Scope

In general, the scope of a pragma setting is limited to a single file.

As discussed in "Pragma Syntax," you should use on, or off after the pragma's name to change a pragma's setting to the condition you want. After you have set the pragma to the desired state, all code after that point is compiled with that setting until either:

At the beginning of each file, the compiler reverts to the project or default settings.

Pragma settings are not stored in a precompiled header file. In other words, you can modify compiler settings inside a precompiled header, but the change affects the code within that file only. The settings that were active at the end of the precompiled header file are lost and have to be set up again.

The settings for an item that is declared in a precompiled header file (such as data or a function) are saved and restored when the precompiled header file is included.

For example, this code says that the variable xxx is a far variable.


// in file pch.h

#pragma far_data on
extern int xxx;

Now, assume a file includes this as a precompiled header.


// in file test.c 
#pragma far_data off // far data is off

#include "pch.pch" // this file set far_data on

// far_data is still 'off' but xxx is still a far variable

The pragma setting still works within the header file, even though the source file including the header has a different setting.


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 17, 2000