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

Add string literal concatenation and stringizing operator #173

Merged

Conversation

Arkshine
Copy link
Member

@Arkshine Arkshine commented Jan 6, 2015

This the same kind of patch as SM: alliedmodders/sourcemod#5
I'm not going to repeat so feel free to see link for more details ^.

This basically allows you to concatenate literal strings and stringizing a parameter in macro substitution only (so possible breakage is very limited ).

As per your suggestion, this uses + instead of ... to concatenate.
Random examples:

#define PROJECT_AUTHOR    "Greyscale"
#define PROJECT_COPYRIGHT "Copyright (C) 2010  " + PROJECT_AUTHOR

#define VERSION_MAJOR      "1"
#define VERSION_MINOR      "8"
#define VERSION_RELEASE    "3"
#define VERSION            VERSION_MAJOR + "." + VERSION_MINOR + "." + VERSION_RELEASE

#define log(%1)  "logging: " + #%1 + "\n"

Also I did not bother to remove checks related to packed string because in AMXX you can still use them in a limited way though, but I know people/plugin using them, this would be fine to let this as it is.

Please don't die again with this horrible code!

@dvander
Copy link
Member

dvander commented Jan 22, 2015

Sure. 🚢

Arkshine added a commit that referenced this pull request Jan 22, 2015
Add string literal concatenation and stringizing operator
@Arkshine Arkshine merged commit 5ca0e56 into alliedmodders:master Jan 22, 2015
@Arkshine Arkshine deleted the feature/compiler-concatenation branch January 22, 2015 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants