tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] stringify, another simple C program which doesn't compil


From: Patrick Hammer
Subject: [Tinycc-devel] stringify, another simple C program which doesn't compile
Date: Sat, 30 May 2020 19:30:41 +0000

Hi!

The second program also works with Clang, gcc etc., but not with tcc.
It tries to use stringification with a backslash, indirectly:

#include <stdio.h>
#define PRINT_(X) puts(#X);
#define PRINT(X) PRINT_(X)

int main(void)
{
    PRINT(\\)
    return 0;
}

Here the workaround is to use no indirection, to use PRINT_(\\) instead of PRINT(\\) or to change the definition of PRINT to #define PRINT(X) puts(#X), in which case the program prints the backslash as expected. However this isn't a good workaround, as avoiding indirections in the macros can sometimes be very annoying, luckily it worked in my program though.

In this case it might be an issue with the preprocessor and not the parser.

Best regards,
Patrick


Attachment: stringify.c
Description: Binary data

Attachment: stringify_workaround.c
Description: Binary data

Attachment: stringify_workaround2.c
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]