Pablo Ariel
Pablo Ariel

Reputation: 283

TypeScript macro expansion

I need to reproduce the functionality of this C code but in typescript. The purpose of this code is mainly to simplify error checking as stated in JPL's The Power of Ten but I couldn't find a way to do it in TS.


#define ecall(retVal, l_call, format, ...) do { \
        int _rv = (l_call);                     \
        if(_rv < 0) {                           \
            printf(format, __VA_ARGS__);        \
            return retVal;                      \
        }                                       \
        else {                                  \
            check();                            \
        }                                       \
    } while(0)

Upvotes: 2

Views: 2782

Answers (1)

D.H.Lolo
D.H.Lolo

Reputation: 125

maybe you can try ts-macro, as its name, impl macro for ts based with ttypescript.

Upvotes: 3

Related Questions