Menu

SyntaxCheck

Brad Lanam

Wiki Home
Syntax

Syntax: Checks

Checks
Standard Headers Included for a Check

The following headers are included for the checks. These headers cover many of the usual types and library calls.

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
Allowed Attributes

Check statements may allow the following attribute statements. Check the specific wiki page for the check to see which attributes are allowed for the check.

Setting Required Headers for a Check

The headers for a check may set by appending a statement block, and using the header attribute.

check_size int64_t {
  header stdint.h;
}
Generated Names

mkc automatically generates names for each check. Each check has an associated prefix. The name of the check will replace characters that are not alphabetic or digits with an underscore.

Changing the Name of a Check

mkc automatically generates names for each check. To change the name of a check, append a statement block and use the name statement.

check_size int64_t {
  header stdint.h;
  name HAVE_INT64;
}
Setting Required Flags for a Check
check_size int64_t {
  compiler_flags '-DANSI';
}
Setting Required Libraries for a Check
check_size int64_t {
  link_flags '-lintl';
}
Alternates

The alternate is a powerful method to run checks with alternate settings.

Each alternate attribute block may contain the name, header, compiler_flags, and link_flags attributes.

For example, the following code checks for the statfs function. On Linux, this requires the sys/vfs.h header (or sys/statfs.h). On MacOS and *BSD, the sys/mount.h header should be used.

check_function statfs {
  alternate {
    # linux
    name _header_sys_vfs;
    header sys/vfs.h;
  }
  alternate {
    # macos, freebsd
    name _header_sys_mount;
    header sys/mount.h;
  }
}

On success, the generated _function_statfs name will be set.

If the first alternate succeeds, the _header_sys_vfs variable will be set. If the second alternate succeeds, the _header_sys_mount variable will be set.

success and failure

The success and failure attributes blocks will execute on success or failure of a check.

check_function statfs {
  alternate {
    name _header_sys_vfs;
    header sys/vfs.h;
  }
  alternate {
    name _header_sys_mount;
    header sys/mount.h;
  }
  success {
    print 'found statfs.';
  }
  failure {
    print 'could not locate statfs.';
  }
}

Wiki Home
Syntax


Related

Wiki: Home
Wiki: Syntax
Wiki: SyntaxAttrAlternate
Wiki: SyntaxAttrCompileFlag
Wiki: SyntaxAttrHeader
Wiki: SyntaxAttrLinkFlag
Wiki: SyntaxAttrName
Wiki: SyntaxAttrPath
Wiki: SyntaxAttrSuccessFail
Wiki: SyntaxCheck
Wiki: SyntaxCheckArgCount
Wiki: SyntaxCheckCompilerFlag
Wiki: SyntaxCheckConstant
Wiki: SyntaxCheckDefine
Wiki: SyntaxCheckFunction
Wiki: SyntaxCheckHeader
Wiki: SyntaxCheckLinkFlag
Wiki: SyntaxCheckPackage
Wiki: SyntaxCheckShell
Wiki: SyntaxCheckSize
Wiki: SyntaxCheckStructMember
Wiki: SyntaxCheckType