Skip to content

Instantly share code, notes, and snippets.

@midnqp
Created August 18, 2022 15:18
Show Gist options
  • Save midnqp/05734f30a622c4c2b8e98c6062fa2e61 to your computer and use it in GitHub Desktop.
Save midnqp/05734f30a622c4c2b8e98c6062fa2e61 to your computer and use it in GitHub Desktop.
C/C++ code using libcpy.h
#include <cpy.h>
int main() {
char* name = new(Str_t);
List* ls = new(List_t);
bool t = type(ls) == List_t; //true
double arr[] = { 1.2, -3.4 };
input(name, "👨🏻‍💻 Username: ");
listAdd(ls, 1.2, -3.4, name);
print(ls, name);
print("🔥 anything", -5.6, t, arr);
}
// Count variadic args
#define function(args...) ({ \
int count = va_argc(args); \
print("Count: ", count); \
})
function(0, 1, 2, 3); // Count: 4
// Overload a function
void _add(int argc, unsigned short argv[], ...);
#define Add(args...) ({ va_argv(_add, args); })
Add(1, 2, 3, 4, 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment