From 8cfd86bc906fb6199263bec5ce59166abbbc7c56 Mon Sep 17 00:00:00 2001 From: asus Date: Wed, 24 Jan 2024 09:38:43 +0100 Subject: [PATCH] grace works, without comments for now --- 2_Grace/Grace.c | 5 +++-- notes.md | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/2_Grace/Grace.c b/2_Grace/Grace.c index 7c8ac31..142679c 100644 --- a/2_Grace/Grace.c +++ b/2_Grace/Grace.c @@ -1,7 +1,8 @@ #include -#define PRINT quine, 10, 10, 92, 10, 34, quine, 34, 92, 10, 92, 10, 92, 10, 10, 10, 10, 10 +#define PRINT quine, 10, print, 10, 92, 10, 92, 10, 34, quine, 34, 92, 10, 92, 10, 92, 10, 10, 10, 10, 10 #define FT(...) int main(){\ - char *quine = "#include %c#define PRINT "#__VA_ARGS__" %c#define FT(...) int main(){%c%c char *quine = %c%s%c;%c%c printf(PRINT);%c%c return 0;%c%c}%c#define FFT(...) FT(__VA_ARGS__)%c%cFFT(PRINT)%c";\ + char *print = #__VA_ARGS__;\ + char *quine = "#include %c#define PRINT %s%c#define FT(...) int main(){%c%c char *print = #__VA_ARGS__;%c%c char *quine = %c%s%c;%c%c printf(PRINT);%c%c return 0;%c%c}%c#define FFT(...) FT(__VA_ARGS__)%c%cFFT(PRINT)%c";\ printf(PRINT);\ return 0;\ } diff --git a/notes.md b/notes.md index b81016c..d7d0fe2 100644 --- a/notes.md +++ b/notes.md @@ -1 +1,4 @@ - [interactions between MACRO and comments](https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html#:~:text=the%20stringized%20result.-,Comments,-are%20replaced%20by) +- [preprocessor strip comments before exapnding macros](https://stackoverflow.com/questions/1510869/does-the-c-preprocessor-strip-comments-or-expand-macros-first) +- [create an include with a macro OR NOT](https://stackoverflow.com/questions/1135822/escaping-a-symbol-in-a-define-macro) +