Initial values for structures
The include file <cmqc.h> defines various macro variables that we can use to provide initial values for the structures when declaring instances of those structures. These macro variables have names of the form MQxxx_DEFAULT, where MQxxx represents the name of the structure. Use them like this:
MQMD MyMsgDesc = {MQMD_DEFAULT}; MQPMO MyPutOpts = {MQPMO_DEFAULT};For some character fields, the MQI defines particular values that are valid (for example, for the StrucId fields or for the Format field in MQMD). For each of the valid values, two macro variables are provided:
- One macro variable defines the value as a string whose length, excluding the implied null, matches exactly the defined length of the field. For example, (the symbol ␢ represents a blank character):
#define MQMD_STRUC_ID "MD␢␢" #define MQFMT_STRING "MQSTR␢␢␢"Use this form with the memcpy and memcmp functions.- The other macro variable defines the value as an array of char; the name of this macro variable is the name of the string form suffixed with _ARRAY. For example:
#define MQMD_STRUC_ID_ARRAY 'M','D','␢','␢' #define MQFMT_STRING_ARRAY 'M','Q','S','T','R','␢','␢','␢'Use this form to initialize the field when an instance of the structure is declared with values different from those provided by the MQMD_DEFAULT macro variable.
Parent topic:
Coding in C
fg11700_