Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprocessor, "to string" conversion #943

Open
Classes123 opened this issue Jan 31, 2024 · 0 comments
Open

Preprocessor, "to string" conversion #943

Classes123 opened this issue Jan 31, 2024 · 0 comments

Comments

@Classes123
Copy link

I don't know if it's a bug or it was designed that way, but the following code gives the "wrong" result:

#define TEST   15

#define _TO_STR(%0) #%0
#define TO_STR(%0)  _TO_STR(%0)

public void OnPluginStart()
{
    PrintToServer(TO_STR(TEST));
}

Result:

TEST

Same code in C:

#define TEST   15

#define _TO_STR(x) #x
#define TO_STR(x)  _TO_STR(x)

int main()
{
    printf(TO_STR(TEST));
    return 0;
}

Result:

15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant