#include <stdio.h> // 引数の数が違う、同じ関数に置き換える #define DEBUG_PRINT(...) printf(__VA_ARGS__) #define DEBUG_PRINT2(fmt, ...) printf(fmt, __VA_ARGS__) // 引数の数が違う、別の関数に置き換える #define GET_MACRO(_1,_2,_3,NAME,...) NAME #define SUM(...) GET_MACRO(__VA_ARGS__, sum3, sum2)(__VA_ARGS__) int sum2(int a,int b) { return a+b; } int sum3(int a,int b,int c) { return a+b+c; } int main(void) { DEBUG_PRINT("num=%d\n",2); D
![[C言語] 可変引数マクロの作り方 - Qiita](https://cdn-ak-scissors.b.st-hatena.com/image/square/cdcd6acd28fe828dcaca8bce516c085fb1199ccf/height=288;version=1;width=512/https%3A%2F%2Fqiita-user-contents.imgix.net%2Fhttps%253A%252F%252Fcdn.qiita.com%252Fassets%252Fpublic%252Farticle-ogp-background-9f5428127621718a910c8b63951390ad.png%3Fixlib%3Drb-4.0.0%26w%3D1200%26mark64%3DaHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZ3PTkxNiZoPTMzNiZ0eHQ9JTVCQyVFOCVBOCU4MCVFOCVBQSU5RSU1RCUyMCVFNSU4RiVBRiVFNSVBNCU4OSVFNSVCQyU5NSVFNiU5NSVCMCVFMyU4MyU5RSVFMyU4MiVBRiVFMyU4MyVBRCVFMyU4MSVBRSVFNCVCRCU5QyVFMyU4MiU4QSVFNiU5NiVCOSZ0eHQtY29sb3I9JTIzMjEyMTIxJnR4dC1mb250PUhpcmFnaW5vJTIwU2FucyUyMFc2JnR4dC1zaXplPTU2JnR4dC1jbGlwPWVsbGlwc2lzJnR4dC1hbGlnbj1sZWZ0JTJDdG9wJnM9NDQ5NDE2YTAzZTZiZGEzYWUxNDcyYjU5MjcyNjBmNGM%26mark-x%3D142%26mark-y%3D112%26blend64%3DaHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZ3PTYxNiZ0eHQ9JTQwc2FsdGhlYWRzJnR4dC1jb2xvcj0lMjMyMTIxMjEmdHh0LWZvbnQ9SGlyYWdpbm8lMjBTYW5zJTIwVzYmdHh0LXNpemU9MzYmdHh0LWFsaWduPWxlZnQlMkN0b3Amcz0xZGMyNTVlZDNjNjk5Y2NjMjg3ZjdiNzVhZTkxN2I4NA%26blend-x%3D142%26blend-y%3D491%26blend-mode%3Dnormal%26s%3Dbacd287d6bd7430c46a077d505dea1e0)