[C]: make program simple - No.2

#include <stdio.h>
#include <stdlib.h>

#define _SUCC 0
#define _FAIL (-1)

#define FOO(_FUNC) foo_##_FUNC

int foo_bar()
{
    printf("[%s] called.\n", __func__);
    return _SUCC;
}

int foo_err()
{
    printf("[%s] called.\n", __func__);
    return _FAIL;
}

int main()
{
    int a = 1, ret = 0;

    if (0 != a)
    {
        ret = FOO(bar)();
    }
    else
    {
        ret = FOO(err)();
    }

    printf("Hello world!\n");
    return _SUCC;
}

你可能感兴趣的:([C]: make program simple - No.2)