#include <X11/Shell.h>
#include <X11/Xatom.h>
#include <Xm/XmStrDefs.h>
#include <Xm/VirtKeys.h>
Therefore, none of these files ever need to be included by your application, as long as you include <Xm/Xm.h>. Since
<Xm/Xm.h> is included by each widget header file, you do not need to include it directly either. If you look closely at
the code, you'll see that just about every necessary header file is included the moment you include your widget header
file. This method of using header files contrasts with the way other Xt−based toolkits, like the Athena toolkit or the
OPEN LOOK Intrinsics Toolkit (OLIT), use header files.
Release 1.2 of the Motif toolkit provides a new header file, <Xm/XmAll.h>, that simply includes all of the public
header files. The <Xm/ExtObject.h>, <Xm/Traversal.h>, <Xm/VaSimple.h>, and <Xm/VendorE.h> header files are
present in Motif 1.1, but they are obsolete in Motif 1.2.
We recommend that you not duplicate the inclusion of header files. One reason is that if you include only the header
files that you need, whoever has to maintain your code can see which widgets you are dealing with in your source
files. Another reason is that duplicating header files is generally bad practice, as you run the risk of redeclaring
macros, functions, and variables.
However, it isn't always easy to prevent multiple inclusions. For example, <Xm/Xm.h> is included by each widget
header file that you include. All of the Motif, Xt and X header files are protected from multiple inclusion using a
technique called ifdef−wrapping. We recommend that you use this method in your own header files as well. The
ifdef−wrapper for <X11/Intrinsic.h> is written as follows:
#ifndef _XtIntrinsic_h
#define _XtIntrinsic_h
/* Include whatever is necessary for the file... */
#endif /* _XtIntrinsic_h */
The wrapper defines _XtIntrinsic_h when a file is first included. If the file is ever included again during the
course of compiling the same source (.c) file, the #ifdef prevents anything from being redeclared or redefined.
Of course, the wrapper prevents multiple inclusion only within a single source file; the next source file that gets
compiled goes through the same test. If the same files are included, the same macros, data types, and functions are
declared again for the benefit of the new file. For this reason, you should never write functions in a header file, since it
would be equivalent to having the same function exist in every source file. Function declarations, however, are
acceptable and expected.
In addition to the widget header files, you will most likely need other include files specific to your application, such as
<stdio.h> or <ctype.h>.
The order of inclusion is generally not important unless certain types or declarations required by one file are declared
in another. In this case, you should include the files in the necessary order. Otherwise, application−specific header
files are usually included first, followed by UI−specific header files (with Xt header files, if any, preceding Motif
header files), followed by system−specific header files.
3.3.2 Setting the Language Procedure
For Release 5 of the X Window System, the X Toolkit was modified to better support internationalization. An
internationalized application retrieves the user's language (called a locale) from the environment or a resource file and
3 The Motif Programming Model3.3.2 Setting the Language Procedure
27

Get Volume 6A: Motif Programming Manual now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.