#can this be done with macros?

9 messages · Page 1 of 1 (latest)

analog flax
#
typedef struct {
    int error_code;
    const char* func_name;
} cfunc;

cfunc do_math(void);
cfunc process_data(void);

cfunc do_math(void) {

    cfunc result = {0};
    result.func_name = __func__;

    if (result.error_code) {
        return result;
    }
    result.error_code = 0;
    return result;
}

cfunc process_data(void) {

    cfunc result = result.func_name; //i wanna somehow do get this
    cfunc result = do_math(); //so the user does not need to pass func name themselves
    if (result.error_code) {
        return result;
    }
    result.error_code = 0;
    result.func_name = __func__;
    return result;
}
ancient pewterBOT
#

When your question is answered use !solved or the button below to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

analog flax
#

ahh i cannot do this its basic information flow lol

ancient pewterBOT
# ancient pewter

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

knotty plover
#

cfunc result = result.func_name; //i wanna somehow do get this

#

time travel?

#

if I'm understanding what I think you were going for, you could use function pointers or _Generic

#

Why are you returning the function name though?