The current working profile is selected on the command line, and all checks that are not within a profile statement will be attached to the currently selected profile.
The profile statement should only be used when a check should only be in a particular profile. e.g.
profile optimized {
add_compiler_flag '-O3';
}
profile debug {
add_compiler_flag '-O0';
}
One issue is when a flag, such as the optimization level used above should not be duplicated. e.g.
add_compiler_flag '-O2'; # default
profile debug {
add_compiler_flag '-O0';
}
would end up adding both -O2 and -O0 to the command line. Instead the default profile must be explicitly named in this case.
profile default {
add_compiler_flag '-O2';
}
profile debug {
add_compiler_flag '-O0';
}
Now, the -O2 flag is only added if no profile is selected.
A check or variable may be made compiler specific by using the compiler attribute.
profile optimized {
compiler c;
add_compiler_flag '-O3';
}
test.mkc:
project {
name test;
compiler c;
}
# int64_t appears within the currently selected profile
check_size int64_t { header stdint.h; }
profile debug {
# _size_int8_t only appears for the debug profile.
check_size int8_t { header stdint.h; }
}
profile release {
# _size_int32_t only appears for the release profile.
check_size int32_t { header stdint.h; }
}
configure {
method auto;
}
Note the default profile.
$ mkc --profile debug test.mkc
-- default profile: debug general
...
-- check size: int64_t : 8
-- check size: int8_t : 1
...
test_config.h:
...
#define _size_int64_t 8
#define _size_int8_t 1
...
Note the default profile.
$ mkc --profile release test.mkc
-- default profile: release general
...
-- check size: int64_t : 8
-- check size: int32_t : 4
...
test_config.h:
...
#define _size_int32_t 4
#define _size_int64_t 8
...