Macro that converts a function name?
#1

Hello, I have a question about macro's.
Is it possible to make a macro that converts a function name to a new name? for example:

Код:
CONVERT_FUNC_NAME(MyFunction)
Which should be rewritten as:

Код:
new_MyFunction
This is what I tried, but that doesn't really work
Quote:

#define CONVERT_FUNC_NAME(%0) new_%0

Reply
#2

I think is not possible, you only could do that with strings
Reply
#3

Well you can hook existing samp functions with y_hook or ASL hook method
Reply
#4

Yes that's the hooking.

Код:
#if defined _ALS_SomeFunction
  #undef SomeFunction
#else
    #define _ALS_SomeFunction
#endif

#define RenamedFunction SomeFunction
Reply
#5

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
Yes that's the hooking.

Код:
#if defined _ALS_SomeFunction
  #undef SomeFunction
#else
    #define _ALS_SomeFunction
#endif

#define RenamedFunction SomeFunction
That's ALS hooking method. More informations here: https://sampforum.blast.hk/showthread.php?tid=574534
For callbacks, I suggest you to use y_hooks instead of ALS method. It's way more simple.
Reply
#6

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
That's ALS hooking method. More informations here: https://sampforum.blast.hk/showthread.php?tid=574534
For callbacks, I suggest you to use y_hooks instead of ALS method. It's way more simple.
Yes and I am already using y_hooks for callbacks, but I've shown him a function, that's what he requested.
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
How doesn't it work? That's exactly how it should be done.

Here's a useless example, but what am I doing wrong?
PHP код:

#define CONVERT_FUNC_NAME(%0) new_%0
new_Myfunction()
{
    print(
"test");
}
public 
OnGameModeInit()
{
    
CONVERT_FUNC_NAME(MyFunction)(); // error 017
    
return 1;

I get the following errors

Код:
error 017: undefined symbol "new_MyFunction"
warning 203: symbol is never used: "new_Myfunction"
Reply
#8

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
Yes that's the hooking.

Код:
#if defined _ALS_SomeFunction
  #undef SomeFunction
#else
    #define _ALS_SomeFunction
#endif

#define RenamedFunction SomeFunction

NO!




That's the hooking!
Reply
#9

Quote:
Originally Posted by Pottus
Посмотреть сообщение

NO!




That's the hooking!
I missed your tongue in cheek replies
Reply
#10

Quote:
Originally Posted by Dignity
Посмотреть сообщение
I missed your tongue in cheek replies
You can bet she wouldn't miss her tongue in a set of cheeks!
Reply
#11

lmao you're right sry
Reply
#12

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
lmao you're right sry
Reply
#13

How could anyone not know what hooking is? Ludacris!
Reply
#14

sorry who?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)