Exemplo n.º 1
0
rs_context * rs_create_context(int api_version, rs_error ** error) try
{
    int runtime_api_version = rs_get_api_version(error);
    if (*error) throw std::runtime_error(rs_get_error_message(*error));

    if ((runtime_api_version < 10) || (api_version < 10))
    {
        // when dealing with version < 1.0.0 that were still using single number for API version, require exact match
        if (api_version != runtime_api_version) 
            report_version_mismatch(runtime_api_version, api_version);
    }
    else if ((major(runtime_api_version) == 1 && minor(runtime_api_version) <= 9) 
          || (major(api_version) == 1 && minor(api_version) <= 9))
    {
        // when dealing with version < 1.10.0, API breaking changes are still possible without minor version change, require exact match
        if (api_version != runtime_api_version) 
            report_version_mismatch(runtime_api_version, api_version);
    }
    else
    {
        // starting with 1.10.0, versions with same patch are compatible
        if ((major(api_version) != major(runtime_api_version)) 
         || (minor(api_version) != minor(runtime_api_version))) 
            report_version_mismatch(runtime_api_version, api_version);
    }

    return rs_context_base::acquire_instance();
}
void check_error()
{
    if(e)
    {
        printf("rs_error was raised when calling %s(%s):\n", rs_get_failed_function(e), rs_get_failed_args(e));
        printf("    %s\n", rs_get_error_message(e));
        exit(EXIT_FAILURE);
    }
}
Exemplo n.º 3
0
int check_error()
{
    if(e)
    {
        fprintf(stderr,"rs_error was raised when calling %s(%s):\n", rs_get_failed_function(e), rs_get_failed_args(e));
        fprintf(stderr,"    %s\n", rs_get_error_message(e));
        return 1;
        //exit(EXIT_FAILURE);
    }
    return 0;
}