Raised This Month: $ Target: $400
 0% 

Solved define replace


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-09-2017 , 14:45   Re: define replace
Reply With Quote #1

And you can do
Code:
#define client_print(%0) whatever(%0)
without getting any errors. The preprocessor just performs find-and-replace with given patterns, it has no knowledge of symbols (meaning it doesn't care if they were already defined) as far as I am aware.

However, your example
Code:
#define client_print(%1,print_chat,%2)     color_print(%1, true, %2)
won't work well as it won't match text like:
Code:
client_print(0, print_chat, "");
client_print(0,print_chat ,"");
because the pattern also takes whitespace into account, meaning that if there isn't exactly ",print_chat," in there, it won't match. Probably the best way to deal with that is to do
Code:
#define client_print(%0,%9print_chat%8,%1) color_print(%0, true, %1)
macro parameters pretty much work like ".*" expression in Regex.

Last edited by klippy; 09-09-2017 at 14:45.
klippy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:55.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode