Got problems with #define
#1

Код:
#include <a_samp>

main(){

  new string[16];
  print(string, sizeof(string), "This is my test string");

  format(string);

}
As you can see function names are switched. The goal is to #define print as format and to #define format as print. How do I achieve this? Thanks
Reply
#2

Whatever you want to do, switching these function names is not a good idea.
Reply
#3

Edit both functions from inside the a_samp.inc
Reply
#4

Why on earth would you want to do that..?
Reply
#5

Quote:

Edit both functions from inside the a_samp.inc

Bad practice

Quote:
Originally Posted by MP2
Посмотреть сообщение
Why on earth would you want to do that..?
This is just a sample problem. There are other functions that you may want to swap the names of. And I do

The question persists... how to achieve that, huh?
Reply
#6

With macros? Terribly:

pawn Код:
static const stock @ub:emptytag;
#define format @ub:@uq:format
#define print @ub:format
#define @uq:format @ub:print
Might run into tag mismatch
Reply
#7

Quote:
Originally Posted by Misiur
Посмотреть сообщение
With macros? Terribly:

pawn Код:
static const stock @ub:emptytag;
#define format @ub:@uq:format
#define print @ub:format
#define @uq:format @ub:print
Might run into tag mismatch
I bet preprocessor gets trapped in a never-ending loop. Compilation process freezes
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)