#define string in string
Code:
#define PROJECT_AUTHOR "Greyscale" Possible? I know in c++ you would use + to concatenate, but not in pawn. And the above doesn't work. It prints PROJECT_AUTHOR (literally), as I expected. |
Re: #define string in string
In C,
#define "String1""String2" works. Don't know if it will in sourcepawn. However, for everyone who's reading this, the method strictly would only work when creating a literal. It will not concatenate at runtime. |
Re: #define string in string
Code:
#define PROJECT_AUTHOR "Greyscale" Otherwise you may be forced to stick a strcat() or Format() in your code to format the author string into the copyright string. |
Re: #define string in string
Frus: I tried that, didn't work :/
I have no idea why, hopefully I did something wrong. I'll try again. Kevin: Doesn't work in SourcePawn. EDIT: Didn't work, Frus. |
Re: #define string in string
Since I assume by you saying it twice you tried both methods, I don't see why
Code:
#define PROJECT_AUTHOR "Greyscale" main is down so I'm going off the syntax by memory, forgive me if the params are in the wrong order. |
Re: #define string in string
Well, yes I'm sure that method works. If that's the only way that really blows.
I was hoping the compiler would be able to compile it into the code as opposed to making a global string constant to do it. |
Re: #define string in string
In C++ you can only use + to concatentate String objects because there is an operator overload for it. You can't do "foo" + "bar".
Our version of the Pawn compiler does not have either a "stringize" operator or a literal string concatenate operator (# and ##, respectively, in the C preprocessor). |
Re: #define string in string
Can't we overload the + operator for strings ourself then?
Like it's done with floats. Code:
stock Float:operator+(Float:oper1, oper2) |
Re: #define string in string
Quote:
|
Re: #define string in string
Quote:
But the problem is it takes the return value. Pawn can't return strings. berni: Did you end up using Format() to work around this? |
All times are GMT -4. The time now is 20:04. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.