Comments (2)
ALS7 hooking method
It's called ALS4, not 7.
In Pawn 3.2 it was possible to "hook" a function using a compiler bug.
Besides 3.2 it works in Pawn 4.0 as well. The behavior has changed in commit 6de1822 to be precise, so ALS4 doesn't work in the development version, but the 4.0 release is unaffected.
Anyway, here's an example of how it worked before 6de1822:
#include <console>
main()
{
print("This is a message from the main() hook #1.\n");
#if defined hook1_main
hook1_main();
#endif
return 1;
}
#if defined _ALS_main
#undef main
#else
#define _ALS_main
#endif
#define main hook1_main
forward hook1_main();
main()
{
print("This is a message from the main() hook #2.\n");
#if defined hook2_main
hook2_main();
#endif
return 1;
}
#if defined _ALS_main
#undef main
#else
#define _ALS_main
#endif
#define main hook2_main
forward hook2_main();
main()
{
print("This is a message from the main() hook #3.\n");
#if defined hook3_main
hook3_main();
#endif
return 1;
}
#if defined _ALS_main
#undef main
#else
#define _ALS_main
#endif
#define main hook3_main
forward hook3_main();
main()
{
print("main()\n");
}
Output:
This is a message from the main() hook #1.
This is a message from the main() hook #2.
This is a message from the main() hook #3.
main()
After that breaking commit the above example doesn't work. The compiler ends up in an endless loop repeatedly printing the following messages:
test.p(39) : warning 208: function "hook3_main" is used before definition, a forward declaration is recommended
test.p(23) : warning 208: function "hook2_main" is used before definition, a forward declaration is recommended
test.p(7) : warning 208: function "hook1_main" is used before definition, a forward declaration is recommended
test.p(39) : warning 208: function "hook3_main" is used before definition, a forward declaration is recommended
test.p(23) : warning 208: function "hook2_main" is used before definition, a forward declaration is recommended
test.p(7) : warning 208: function "hook1_main" is used before definition, a forward declaration is recommended
...
It would be great if the old behavior could have been brought back.
from pawn.
Corrected in commit 9895412.
The warnings for the three hook functions are still being output, but the compiler does not fall in an endless loop anymore.
from pawn.
Related Issues (20)
- printf is broken for negative numbers HOT 2
- compiler miscalculates unsigned shift right HOT 2
- pawndisasm broken for 64 bit cell size files HOT 1
- size check of packed arrays broken on 64 bit cell size HOT 1
- gtkcalc.p example has syntax errors HOT 1
- Pawn UI is not loaded!
- Some 64 bit defines appear to be set to default on 32 bit MSVC builds HOT 1
- Building Pawn for OpenWatcom v2
- Can I use 32-bit cells on 64-bit only processors?
- `push()` trick in amx_process is an error in latest MSVC HOT 1
- `lseek` `SEEK_SET` fails on Windows HOT 3
- 64 bit windows builds, but scripts fail. HOT 12
- Empty body main generates wrong output HOT 1
- Problem debugging in wxquincy HOT 2
- amx_init --> cannot dynamically load position-independent executable
- what is the best way to hook Pawn Callback using amx.h
- Inaccurate description of SWAP.pri/alt mnemonic in Pawn_Implementer_Guide.pdf
- The problem is with running in the x64 application.
- Current master does not build on Linux x86_64
- Version number is too large to fit in the 32 or 64 bit space of old mach-o format
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pawn.