How can I make a user error appear in the compiler? (#error)
#1

in pawn-lang.pdf I read that #error is used for displaying user errors when compiling.

I tried to use this in one of my plugins, but I seem to need some help with this:

Code:
stock F_SetMenuTitleBoxColor(menuid, color)
{
	if(MenuInfo[menuid][UsedMenu] == true)
	{
		TextDrawBoxColor(MenuInfo[menuid][T_Title], color);
		return 1;
	}
	else
	{
		#error menuid doesn't exist.
		return 0;
	}
}
this is how I tried to use it, but the error just always appears.
can anyone please give me an example of how I can do this? thanks in advance.
Reply
#2

ask JeNkStAX or Y_Less for this
they are really excellente with the plugins
Reply
#3

well I'm waiting for people like them to reply here
Reply
#4

Like #define, it will parse before compilng.
It should use with #if #elseif
Use printf to instead.
Reply
#5

Quote:
Originally Posted by yezizhu
Like #define, it will parse before compilng.
It should use with #if #elseif
Use printf to instead.
I tried using #else and #if before, but I can't get this working
And no, I need #error, not print
Reply
#6

I cann't expression well by my poor english.
Function is run-time compiling, defintion is compiling before run-time, so defintion does't recognize function's logcal(if else, etc)
This may contain in pawn-lang.pdf.

F*ck my poor english up/ : (
Reply
#7

It Does recognise if and else if you use #if and #else.
but I don't know how to use them for what I want to do..
Reply
#8

It works something like
Code:
#define USE_MENU (true)
stock use_menu(){
  #if USE_MENU
  {
  }
  #else
    #error menu doesn't use
  #endif
  return USE_MENU
}
Reply
#9

well I tried that, but I always get the error, even when the function Is used correctly.
Reply
#10

Look ysi/core/ysi_bit.own
It has an usage about #error

Sorry, I a'nt able to explain more.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)