A first and easy test that AML is set up properly and can be linked with a user program is to try to check that the headers and the library version match. All AML programs must also start by initializing the library and must end with a call to the cleanup function.
aml_init
aml_finalize
AML defines its version using semantic versioning, with a macro and variable for each subcomponent of the version number:
- Version major: denotes ABI changes which prevent compatibility with previous major version ABI.
- Version minor: denotes new features or improvement without breaking the old ABI.
- Patch version: patch and fix releases only.
The full version string is also available directly.
/* see aml/utils/version.h for details */
#define AML_VERSION_MAJOR ...
#define AML_VERSION_MINOR ...
#define AML_VERSION_PATCH ...
#define AML_VERSION_STRING ...
extern const int aml_version_major = ...;
extern const int aml_version_minor = ...;
extern const int aml_version_patch = ...;
extern const char *aml_version_string = ...;
Both the setup and the version APIs are available directly from the main AML header.
#include <aml.h>
Initialization is done by passing pointers to the command-line arguments of the program to the library.
int main(int argc, char **argv){
...
if(aml_init(&argc, &argv) != 0){
fprintf(stderr, "AML library init failure!\n");
return 1;
}
Checking that the program is linked against the same version as the one used during compilation is as easy as comparing the header version AML_VERSION_MAJOR and the library-embedded version aml_version_major.
if(aml_version_major != AML_VERSION_MAJOR){
fprintf(stderr, "AML ABI mismatch!\n");
return 1;
}
Write a "hello world" code that checks both major and minor versions of the code.
Click Here to Show/Hide Code
0_hello.c
You can find this solution in doc/tutorials/hello_world/.