Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9154635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:27:30+00:00 2026-06-17T12:27:30+00:00

Well, I have an abstract virtual machine ( PAWN ) which is running from

  • 0

Well, I have an abstract virtual machine (“PAWN“) which is running from my code and the scripts can execute functions, those functions are registered to the script from the C code which gets executed by my C++ code.

The c++ code has to supply an array in the form of

{ "name_i_want_the_function_to_have_in_the_script" , function_in_my_cpp_code }

if the function is not in the array, it cannot be executed. (because it doesn”t “exist”)

So this brings us to this:

My functions look like this:

//Pawn Functions
#define PWNFUNC(a) static cell AMX_NATIVE_CALL a(AMX *amx, cell *params)

namespace PawnFunc
{
    PWNFUNC(GGV)
    {
        return pGameInterface->FindGameVersion();
    }
};//namespace PawnFunc

and the array with the scripting functions information is in another file, like this:

AMX_NATIVE_INFO custom_Natives[] =
{
    {   "GetGameVersion", PawnFunc::GGV   },
    {   0,0   }
};

and the question is now:

is it possible to make that array auto updated? (before/at compile time or code initialization time)

as for now I have to add each function manually. Which is sometimes annoying and more prone for errors.

I would like to change it so I could do:

//Pawn Functions
#define PWNFUNC(a,b) ...?...

namespace PawnFunc
{
    PWNFUNC(GGV,GetGameVersion)//{ "GetGameVersion", PawnFunc::GGV }, is now added to "custom_Natives" array
    {
        return pGameInterface->FindGameVersion();
    }
};//namespace PawnFunc

Is this possible at all? If yes, how could I achieve this?

maybe it is possible to loop the namespace?

Edit: here is some pseudo code: http://ideone.com/btG2lx

And also a note: I can do it at runtime, but then it has to be done at DLLMain (my program is a DLL).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:27:31+00:00Added an answer on June 17, 2026 at 12:27 pm

    This #define will do the job, if you use a std::vector as the storage for your script info.

    (Note that the standard guarantees that you’ll still get a C-style array from &custom_Natives[0])

    std::vector<AMX_NATIVE_INFO> custom_Natives;
    
    #define PWNFUNC(NAME, FUNC) \
     struct IMPL_ ## FUNC { \
       IMPL_ ## FUNC() { \
         AMX_NATIVE_INFO entry = { NAME, PawnFunc::FUNC }; \
         custom_Natives.push_back( entry ); \
       } \
     } INSTANCE_ ## FUNC; \
     static cell AMX_NATIVE_CALL FUNC(AMX *amx, cell *params)
    

    Now code like this will both define the function and add the script entry to custom_Natives.

    PWNFUNC("GetGameVersion", GGV)
    {
        return pGameInterface->FindGameVersion();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stateless, abstract base class from which various concrete classes inherit. Some
I have a controller which inherits from an abstract secure controller which holds a
I have an abstract base class T , from which classes A and B
I have an abstract base class class IThingy { virtual void method1() = 0;
I am from an XP background. I know the process very well and have
In a system for managing vocational training, I have a CourseBase abstract class, which
I have an abstract entity that 4 other entities inherit from. This relationship works
I have a two classes User Profile and FingerprintProfile which extend an abstract class
I have an abstract class holding a number of fields which are inherited by
Consider I have some abstract Vehicle class and car, truck, motorcycle abstract classes which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.