Initial values for structures

The header files define various macro variables used to provide initial values for the MQ structures when we declare instances of those structures.

These macro variables have names of the form MQxxx_DEFAULT, where MQxxx represents the name of the structure. They are used in the following way:
MQMD   MyMsgDesc = {MQMD_DEFAULT};
MQPMO  MyPutOpts = {MQPMO_DEFAULT};
For some character fields (for example, the StrucId fields that occur in most structures, or the Format field that occurs in MQMD), the MQI defines particular values that are valid. For each of the valid values, two macro variables are provided:

  • One macro variable defines the value as a string with a length, excluding the implied null matches, exactly the defined length of the field. For example, for the Format field in MQMD the following macro variable is provided (¬ represents a blank character):
    #define MQFMT_STRING "MQSTR¬¬¬"
    
    Use this form with the memcpy and memcmp functions.
  • The other macro variable defines the value as an array of characters; the name of this macro variable is the name of the string form suffixed with _ARRAY. For example:
    #define MQFMT_STRING_ARRAY 'M','Q','S','T','R','¬','¬','¬'
    
    Use this form to initialize the field when we declare an instance of the structure with values different from those provided by the MQMD_DEFAULT macro variable. (This is not always necessary; in some environments you can use the string form of the value in both situations. However, we can use the array form for declarations, because this is required for compatibility with the C++ programming language.)

Parent topic: C programming