Giter Club home page Giter Club logo

compiler's Introduction

Pawn Community Compiler

Build Status Build Status - Windows

What

This is a modified version of the Pawn 3.2.3664 compiler with many bug fixes and enhancements.

This project was originally started by Zeex but on 2017-12-31, the project was taken over by some members of the SA:MP community. Zeex still contributes to the project, along with the Compiler Team.

The original readme is available here

Why

This project exists to:

  • Fix known bugs with the original compiler
  • Provide a better development experience for the SA:MP community

If you find a problem, you can open an issue and contributors can work on a fix. This isn't true with the original compiler that comes with the SA:MP server distribution.

There are also new features that enhance the development experience, such as telling you which tags are involved in a "tag mismatch" or showing you where that pesky "symbol is never used" is actually declared.

There are plenty of features and fixes that are documented, see below for links:

  • Known compiler bugs contains a list of bugs that the team are aware of with their status.

  • What's new contains features and other notable changes.

  • Release notes list of all official releases of the compiler binaries.

How to Use

Binary packages can be downloaded from Releases, see the below sections for platform-specific installation instructions.

Note: You will probably get warnings/errors/fatals when you first build with this compiler β€” you need to add the -Z flag to your build configuration or add #pragma compat. See this page for more information.

You can also get the latest development binaries for Windows on AppVeyor. This archive is built automatically on every Git commit and can be pretty unstable, so use at your own risk.

Windows

If you just use an editor configured to run pawncc such as Pawno, Sublime Text or VS Code you can simply delete your existing pawncc.exe and replace it with the new one.

Download the ZIP archive and extract pawnc.dll, pawncc.exe, pawndisasmsm.exe to your original pawncc directory. If you use Pawno, this will be in the pawno/ folder that's inside your server directory.

openSUSE

There is an installation package available for openSUSE users so that you can easily install the latest compiler on your distribution. Please follow these steps:

  1. Go to https://build.opensuse.org/package/show/home:mschnitzer:pawncc/pawncc
  2. On the right side, select your distribution (only if it's not disabled!)
  3. Click "Go to download repository"
  4. Copy the link and enter in sudo mode in your shell: zypper ar $COPIED_LINK home:mschnitzer:pawncc
  5. Again as root, type: zypper ref
  6. Install the package with zypper in pawncc
  7. Run pawncc in your shell to test if it's working

The download repository for openSUSE does provide older versions as well (oldest version: 3.10.7). Just install the version you like (e.g.: zypper in pawncc-3.10.8 and run it via $ pawncc-3.10.8 -Z -O3 [...]). Parallel installation is supported.

With sampctl

If you are a sampctl user, you are already using this compiler!

Building from Source

If you are interested in contributing then please first read this document and ensure you have discussed your proposed changes before writing any code. Check out this page for instructions for compiling for your platform.

Background

The project was originally started as a set of patches aimed to create a compiler that would be compatible with the compiler used in SA-MP (San Andreas Multiplayer).

SA-MP uses a modified version of Pawn 3.2.3664 [1] with Windows-only executables, and the developers said that they lost the source code for it which means it can't be ported to other platforms (e.g. Linux) and newly discovered bugs can't be fixed. So the main goal of the project is to re-create changes that were previously made by the devs as well as fix all known compiler bugs.

[1] It's worth noting that the version of the AMX embedded into the SA-MP server seems to be based on an older release of Pawn.

compiler's People

Contributors

agraber avatar amyrahmady avatar daniel-cortez avatar gitter-badger avatar maddinat0r avatar misiur avatar mschnitzer avatar oscar-broman avatar southclaws avatar spacemud avatar sysadminjeroen avatar vvwvv avatar y-less avatar yashassamaga avatar zeex avatar ziggi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

compiler's Issues

/ \ problem with directory

i tried compiling my script πŸ‘ but i needed to edit a lot of files from YSI because of the slash problems im planning to make an online IDE for my friend but it will cause problems (the slashes)

"cannot open shared object file" on Debian 7

I tried to use the latest release for Linux on my server (Debian 7.4 x64).

But if I try to execute the pawn compiler I get the following error:
./pawncc: error while loading shared libraries: libpawnc.so: cannot open shared object file: No such file or directory

Strings in ternary operator fix causes issues

In 0c8f234 you fixed strings in ternary operators, which breaks the following line of code (created by macros):

new  Response__;static const Response[]=# Response":..."#@Ia#@Ib#@Ib#@Ib#@Ib#@Ib#@Ic#:iiiis;for(new  pid, dialogid, response, listitem,text0[(130)];Inline_Loop(.y= Response__,.f= Response);)

Compiling with the old compiler works, while the new one generates an error.

stgbuf, stgpipe, stgmark: (un)signed char

The problem that may concern some compilers is that "sEXPRSTART" is defined as 0x80 and buffers "stgbuf", "stgpipe", function "stgmark" and other releated functions which deal with them are defined as "char" which if the compiler defines it to be "signed" means that the maximum is SCHAR_MAX which is 2^7-1 or 127 or 0x7F clearly causing overflow, if the compiler defines the "char" as "unsigned" then there won't be any problems because the maximum is UCHAR_MAX which is 2^8-1 or 255 or 0xFF. Note that "sEXPRSTART" directly relates to the "sMAXARGS" defined as 127(0x7F) which is maximum amount of arguments. Probably the best solution is to define everything that concerns those buffers as "unsigned char" and cast it to appropriate "char" where needed(e.g. strlen).

Unhandled exception at 0x5C8C3F18 (pawnc.dll)

Hi,

I have a 100k+ lines gamemode, but after i hit compile, the compiler crash after ~1 second.
I just now changed from an older version of your Compiler with the line-limit patch, the current version of the compiler is the default (without line-limit patch)
Unhandled exception at 0x5C8C3F18 (pawnc.dll) in pawncc.exe: 0xC0000005: Access violation reading location 0x00000036.

What cause this?

EDIT:
I think i found the bug, Slice's formatnumber include cause the compiler crash.
http://forum.sa-mp.com/showthread.php?t=184328

To reproduce:

#include <formatnumber>
main()
{
}

Can you fix this bug?

Thank you

Compiling YSI

So I started porting YSI to run on this new compiler version, but I'm afraid it keeps crashing. So far, for no apparent reason, it crashes on:

https://github.com/Y-Less/YSI-Includes/blob/YSI.tl/YSI_Core/y_debug.inc#L283
https://github.com/Y-Less/YSI-Includes/blob/YSI.tl/YSI_Core/y_testing.inc#L192
https://github.com/Y-Less/YSI-Includes/blob/YSI.tl/YSI_Core/y_utils.inc#L845

I would comment out or not include one and find the next crash, 3 is all I bothered to do. The first one shouldn't be the same issue as before of natives not being included, because I know that one is - y_funcinc ensures that (and it works on the old compiler). This is with -d3 and can be reproduced with only:

#include <a_samp>

#include <YSI_Coding\y_hooks>

Macro contents detection

This:

#define A%0\10;%1 B
#define B%0B C

A

When compiled with "-l" produces "C". My understanding of the pre-processor is that it should produce just "B"...

Multidimensional arrays different behaviour with compability mode

Try this snippet in standard compiler, and with this compiler in compability mode:

#include <a_samp>

new foo[3][2][] = {
    {"Bar","Bar"},
    {"Boo","Boo"},
    {"Bee","Bee"}
};

main() {
    printf("%d, %s", sizeof foo, foo[0][0]);
}

Expected result: All is well
Actual result: error 052, multidimensional-arrays must be fully initialized

No idea why, maybe new ellipsis support changed that.

edit: Compability mode doesn't matter, it still reports this error

Recursive relative include doesn't change CWD when using forward slash

Assume a matryoshka of kinds:

- test.pwn
- level_1
-- test.inc
-- level_2
--- test.inc
--- level_3
---- test.inc

When using backslash to specify path to included file, everything is nice. However, only that setup will work:

test.pwn

#include "level_1/test"

level_1/test.inc

#include "level_1\level_2/test"

level_2/test.inc

#include "level_1\level_2\level_3/test"

Is this intended behaviour?

Check string size in ternary operator

This should not compile:

#include <a_samp>

GetString() {
    new s[1] = {'0'};
    return s;
}

main() {
    new x = 0;
    new s[2];
    s = x ? "1" : GetString(); // "Invalid memory access" at runtime
    printf("%s", s);
}

The compiler should check if the sizes of the two arrays match like it does here:

GetString() {
    new s[] = "hello";
    return s;
}

main() {
    new s[1];
    s = GetString(); // error 047: array sizes do not match, or destination array is too small
}

Linux compiler hangs if include file is a directory

When using #include <somefile> and there's a directory with the same name the compiler will try to read the directory first and only when that fails will it append the .inc extension. This doesn't work great on Linux where fopen won't fail and return NULL even if the filename points to a directory.

For example, this is what happens when you #include <YSI_Coding/y_inline> from YSI 4.0:

open("/samp/include/YSI/YSI_Coding/y_inline", O_RDONLY) = 5
fstat64(5, {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xfffffffff76d5000
_llseek(5, 0, [0], SEEK_CUR)            = 0
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
_llseek(5, 0, [0], SEEK_SET)            = 0
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
read(5, 0xf76d5000, 4096)               = -1 EISDIR (Is a directory)
...

The include files

For some reason, even if I move pawncc and libpawnc.so to /usr/bin and /usr/lib, it includes include/default.inc.
It started failing because print and printf were already defined, and it took a while until I found where they came from.

Are the default include files really needed?

warning 203: symbol is never used: "rouletteOffsets"

I'm using the latest binaries provided on the release page. (pawncc 2014/08/31)

Declaring variable:
http://pastebin.com/H0kXEYdv

I use it as parameter in this function call (http://pastebin.com/6SrNFa73) and in combination with 'sizeof' keyword.

//Later edit: I don't know if it is indeed a problem or it is my fault ( as I'm using it in combination with a tweak that allows me to create 4 dimensional arrays ). However, I found a work-around: moving entire code from include file to gamemode ( I had that variable and some other codes declared in a include file and used in gamemode. After I moved that content to gamemode header, it compiled perfectly. )

Linux compiling fail

Hello,

I've tried compiling my gamemode using linux compiler

mike@Mike-G550 /GM_LINUX/new_lin $ ls -all

total 160
drwxr-xr-x 3 mike mike   4096 Jan 29 17:16 .
drwxr-xr-x 6 mike mike   4096 Jan 29 16:36 ..
-rwxr-xr-x 1 mike mike    175 Jan 29 16:38 compile.sh
drwxr-xr-x 3 mike mike   4096 Dec  9  2012 include
-rw-r--r-- 1 mike mike 143910 Dec  9  2012 DB.pwn

with the following args (shell script):
mike@Mike-G550 /GM_LINUX/new_lin $ cat compile.sh

#!/bin/bash
FISIER=$1
/GM_LINUX/pawno-c/pawncc $FISIER -i./include "-;" "-(" "-O1"

And, compiling fails with the following errors:
mike@Mike-G550/GM_LINUX/new_lin $ ./compile.sh newegDB.pwn

Pawn compiler 3.2.3664.samp         Copyright (c) 1997-2006, ITB CompuPhase

./include/GM_functii/GM_comune.inc(1688) : error 029: invalid expression, assumed zero
./include/GM_functii/GM_comune.inc(1688) : error 008: must be a constant expression; assumed zero
./include/GM_functii/GM_xan_Bizuri.inc(1447) : error 029: invalid expression, assumed zero
./include/GM_functii/GM_xan_Bizuri.inc(1447) : error 008: must be a constant expression; assumed zero
./include/GM_functii/GM_xan_Arme.inc(79) : error 029: invalid expression, assumed zero
./include/GM_functii/GM_xan_Arme.inc(79) : error 008: must be a constant expression; assumed zero

./include/GM_functii/GM_comune.inc(1688)

AntiDeAMX()
{
        new a[][] =
        {
                "Unarmed (Fist)",
                "Brass K",
        }; //-- line 1688
        #pragma unused a
}

./include/GM_functii/GM_xan_Bizuri.inc(1447)

stock NumeProdus(idprod)
{
    static const  sc_numeprod[][MAX_PROD_NAME] =
        {
            "\1",              
            "Cell Phone",      
        .....   // more lines here
        bla bla // more lines here
        }; //-- line 1447
    if (0 <= idprod <= MAX_PRODUSE)
    {
        return sc_numeprod[idprod];
    }
    return sc_numeprod[0];
}

./include/GM_functii/GM_xan_Arme.inc(79) 
new GunNames[51][MAX_GUN_NAME] = {
        "Nothing",
        "BrassKnuckles",
        "GolfClub",
        "Nitestick",
        "Knife",
        "BaseballBat",
..
...
...
        "Drugs",
}; //-- line 79

Any suggestions how to make it compile on linux?
Standard windows compiler from samp package.. is fine with the same parameters.

Thank you in advance,
Mike.

Server crash by using asm-format functions (pawncc 2015/04/07)

In new version pawncc 2015/04/07, functions with asm-format cause the server crash if i use more than one formatting param.

Example script:

#include "compiler/includes/a_samp"

#define BYTES_PER_CELL          4

stock example_log(fstring[], {Float, _}:...)
{
    static const STATIC_ARGS = 1;
    new n = (numargs() - STATIC_ARGS) * BYTES_PER_CELL;
    if (n)
    {
        new message[144], arg_start, arg_end;
        #emit CONST.alt         fstring
        #emit LCTRL             5
        #emit ADD
        #emit STOR.S.pri        arg_start

        #emit LOAD.S.alt        n
        #emit ADD
        #emit STOR.S.pri        arg_end
        do
        {
            #emit LOAD.I
            #emit PUSH.pri
            arg_end -= BYTES_PER_CELL;
            #emit LOAD.S.pri    arg_end
        }
        while(arg_end > arg_start);

        #emit PUSH.S            fstring
        #emit PUSH.C            144
        #emit PUSH.ADR          message

        n += BYTES_PER_CELL * 3;
        #emit PUSH.S            n
        #emit SYSREQ.C          format

        n += BYTES_PER_CELL;
        #emit LCTRL             4
        #emit LOAD.S.alt        n
        #emit ADD
        #emit SCTRL             4

        printf(message);
    }
    else
    {
        printf(fstring);
    }
    return 1;
}

public OnGameModeInit()
{
    example_log("%d %d", 2, 2);
    return 1;
}

I got this crashdetect log:

[18:36:39] [debug] Server crashed while executing default.amx
[18:36:39] [debug] AMX backtrace:
[18:36:39] [debug] #0 native format () [00471d20] from samp-server.exe
[18:36:39] [debug] #1 000001a4 in example_log (fstring[]=@0x00000004 "%d %d", ... <2 arguments>) at sources\default.pwn:37
[18:36:39] [debug] #2 000002b8 in public OnGameModeInit () at sources\default.pwn:54
[18:36:39] [debug] Native backtrace:
[18:36:39] [debug] #0 0046ce66 in ?? () from samp-server.exe

sources\default.pwn:37 is here:

n += BYTES_PER_CELL;

I think this is a bug

Pawn compiler 3.2.3664.samp Copyright (c) 1997-2006, ITB CompuPhase

/root/include/a_http.inc(22) : error 021: symbol already defined: "HTTP"
/root/include/YSI/internal/y_version.inc(194) : error 021: symbol already defined: "YVers_Callback"
/root/include/YSI/y_scripting.inc(86) : warning 219: local variable "addr" shadows a variable at a preceding level
/root/include/YSI/y_scripting.inc(109) : warning 219: local variable "addr" shadows a variable at a preceding level
/root/include/YSI/y_scripting.inc(299) : warning 219: local variable "addr" shadows a variable at a preceding level
/root/include/YSI/y_scripting.inc(452) : warning 219: local variable "addr" shadows a variable at a preceding level
/root/include/YSI/y_scripting.inc(571) : warning 219: local variable "addr" shadows a variable at a preceding level
/root/include/YSI/y_scripting.inc(622) : warning 219: local variable "addr" shadows a variable at a preceding level
/root/include/a_http.inc(22) : error 021: symbol already defined: "HTTP"
/root/include/YSI/internal/y_version.inc(122) : error 021: symbol already defined: "YVers_OnScriptInit"
/root/include/YSI/internal/y_version.inc(194) : error 021: symbol already defined: "YVers_Callback"
/root/include/a_http.inc(22) : error 021: symbol already defined: "HTTP"
/root/include/YSI/internal/y_version.inc(122) : error 021: symbol already defined: "YVers_OnScriptInit"
/root/include/YSI/internal/y_version.inc(194) : error 021: symbol already defined: "YVers_Callback"
/root/include/YSI/y_als.inc(59) : error 017: undefined symbol "inc_y_als"
/root/include/YSI/y_als.inc(59) : error 010: invalid function or declaration
/root/include/a_http.inc(22) : error 021: symbol already defined: "HTTP"
/root/include/YSI/internal/y_version.inc(122) : error 021: symbol already defined: "YVers_OnScriptInit"
/root/include/YSI/internal/y_version.inc(194) : error 021: symbol already defined: "YVers_Callback"
/root/include/a_http.inc(22) : error 021: symbol already defined: "HTTP"
/root/include/YSI/internal/y_version.inc(122) : error 021: symbol already defined: "YVers_OnScriptInit"
/root/include/YSI/internal/y_version.inc(194) : error 021: symbol already defined: "YVers_Callback"
/root/include/YSI/internal/y_shortfunc.inc(96) : error 021: symbol already defined: "U@"
/root/include/YSI/internal/y_shortfunc.inc(97) : error 021: symbol already defined: "V@"
/root/include/YSI/internal/y_shortfunc.inc(100) : error 021: symbol already defined: "W@"
/root/include/YSI/internal/y_shortfunc.inc(101) : error 021: symbol already defined: "P@"
/root/include/YSI/internal/y_shortfunc.inc(102) : error 021: symbol already defined: "O@"
/root/include/a_http.inc(22) : error 021: symbol already defined: "HTTP"
/root/include/YSI/internal/y_version.inc(122) : error 021: symbol already defined: "YVers_OnScriptInit"
/root/include/YSI/internal/y_version.inc(194) : error 021: symbol already defined: "YVers_Callback"
/root/include/YSI/internal/y_funcinc.inc(60) : error 021: symbol already defined: "
@y_funcinc@_"
/root/include/YSI/y_hooks.inc(432) : error 021: symbol already defined: "YVers_OnScriptInit"

Compilation aborted.

26 Errors.

on windows it is compiling properly maybe a bug with undefining?

2-dimensional array (Bug?!)

my pawno shows error with 2-dimensional array:

With single array:
image

With multi-dimensional:
image

This is a bug, or my code is wrong? O.o

*Sorry for my bad english.

Version pawncc 2015/04/07 with YSI

Hello,

i'm not sure if is an problem from YSI or the compiler however only is happening with new version of compiler.

I get this errors:

[09/04/2015 00:15:44] οΏ½οΏ½οΏ½*** YSI Error: Could not determine pattern type in y_inline
[09/04/2015 00:12:51] οΏ½οΏ½οΏ½*** YSI Error: Format specifier didn't match on inline function Login:..οΏ½@ia@Ib@Ib@Ib@Ib@Ib@Ic:iiiis

y_inline: https://github.com/Y-Less/YSI-Includes/blob/master/y_inline.inc

well with the version of pawncc 2014/11/16 & pawndisasm 2014/11/16 this works well without any problem, any idea what can be?

Well crashdetect dont say anything...

-i (path for include files) option for Linux compiler does not work

-i option on Windows works fine, but on Linux this ignored.

I have this file struct:

.
β”œβ”€β”€ !compile.sh
β”œβ”€β”€ !compile.bat
β”œβ”€β”€ compiler
β”‚Β Β  β”œβ”€β”€ includes
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ a_http.inc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ a_npc.inc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ a_objects.inc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ a_players.inc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ a_sampdb.inc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ a_samp.inc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ a_vehicles.inc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ core.inc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ datagram.inc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ file.inc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ float.inc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ string.inc
β”‚Β Β  β”‚Β Β  └── time.inc
β”‚Β Β  β”œβ”€β”€ libpawnc.so
β”‚Β Β  β”œβ”€β”€ pawncc
β”‚Β Β  β”œβ”€β”€ pawncc.exe
β”‚Β Β  β”œβ”€β”€ pawncc.pdb
β”‚Β Β  β”œβ”€β”€ pawnc.dll
β”‚Β Β  └── pawnc.pdb
β”œβ”€β”€ gamemodes
β”œβ”€β”€ plugins
β”œβ”€β”€ scriptfiles
└── sources
    └── Open-GTO.pwn

!compile.sh:

#/bin/bash

export LD_LIBRARY_PATH=$(pwd)"/compiler/:$LD_LIBRARY_PATH"

NAME="Open-GTO"

./compiler/pawncc "-;+ -(+ -icompiler/includes" sources/$NAME.pwn

if [ $(stat -c%s "$NAME.amx") -gt 0 ];
then
    mv $NAME.amx gamemodes/
else
    rm $NAME.amx
fi

!compile.bat:

set name=Open-GTO
compiler\pawncc.exe -;+ -(+ -icompiler/includes sources\%name%.pwn
if exist %name%.amx ^
move %name%.amx gamemodes\
pause

On Linux i get this error:

compiler/includes/a_samp.inc(17) : fatal error 100: cannot read from file: "core"

On Windows all works fine.

Currently i made this "hack":
I changed it in a_samp.inc:

#include <core>
#include <float>
#include <string>
#include <file>
#include <time>
#include <datagram>
#include <a_players>
#include <a_vehicles>
#include <a_objects>
#include <a_sampdb>

on it:

#include "compiler/includes/core"
#include "compiler/includes/float"
#include "compiler/includes/string"
#include "compiler/includes/file"
#include "compiler/includes/time"
#include "compiler/includes/datagram"
#include "compiler/includes/a_players"
#include "compiler/includes/a_vehicles"
#include "compiler/includes/a_objects"
#include "compiler/includes/a_sampdb"
#include "compiler/includes/a_http"

Adding a pragma directive

Can't you add a pragma to hide a specific warning at compilation ?
For exemple, #pragma warning 203 will hide each warning 203 from the compile log.

strcmp issue with linux compiler

Hello,

I'm here reporting some problem which I ran into when I tried compiling my gamemode with linux compiler.

if (!strcmp(params, "primary"))

Doesn't work, it always, returns 0, whatever 'params' is.

if ( !strcmp(params, "primary", false, 6) )

It is working.
Now, my entire gamemode is broken, unless I rewrite each and every part where I use strcmp into 4 parameters variant.

Using latest SA:MP server 0.3z. Proof of concept GM, reproducing the issue:

#include <a_samp>
#include <zcmd>
new bool:gPlayerSpawned[MAX_PLAYERS char];

main()
{
    print(" test strcmp ");
    return 1;
}

public OnGameModeInit()
{
    SetGameModeText("test strcmp");
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetSpawnInfo( playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 26, 36, 28, 150, 0, 0 );
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SendClientMessage(playerid, -1, "Commands: /debug1 /debug2");
    gPlayerSpawned{playerid} = true;
    return 1;
}

COMMAND:debug1(playerid,params[])
{
    if(gPlayerSpawned{playerid})
    {
        if (isnull(params)) {
            SendClientMessage(playerid, -1, "|__________________ Spawn __________________|");
            SendClientMessage(playerid, -1, "USAGE: /debug  [primary / secondary]");
            SendClientMessage(playerid, -1, "|___________________________________________|");
        }
        else
        {
            printf(params);
            if (!strcmp(params, "primary"))
            {
                print("1");
                SendClientMessage(playerid, -1, "primar.");
                GameTextForPlayer(playerid, "~r~Primary", 1500, 1);
            }
            else if (!strcmp(params, "secondary"))
            {
                print("2");
                SendClientMessage(playerid, -1, "secundar.");
                GameTextForPlayer(playerid, "~r~Secondary", 1500, 1);
            }
            else SendClientMessage(playerid, -1, "Choose between primary and secondary !");
        }
    } else SendClientMessage(playerid, -1, "You can't use this action right now. Try again later!");
    return 1;
}

COMMAND:debug2(playerid,params[])
{
    if(gPlayerSpawned{playerid})
    {
        if (isnull(params)) {
            SendClientMessage(playerid, -1, "|__________________ Spawn __________________|");
            SendClientMessage(playerid, -1, "USAGE: /debug  [primary / secondary]");
            SendClientMessage(playerid, -1, "|___________________________________________|");
        }
        else
        {
            printf(params);
            if ( !strcmp(params, "primary", false, 6) )
            {
                print("1");
                SendClientMessage(playerid, -1, "primar.");
                GameTextForPlayer(playerid, "~r~Primary", 1500, 1);
            }
            else if ( !strcmp(params, "secondary", false, 9) )
            {
                print("2");
                SendClientMessage(playerid, -1, "secundar.");
                GameTextForPlayer(playerid, "~r~Secondary", 1500, 1);
            }
            else SendClientMessage(playerid, -1, "Choose between primary and secondary !");
        }
    } else SendClientMessage(playerid, -1, "You can't use this action right now. Try again later!");
    return 1;
}

Any suggestions?

Thank you in advance,
Mike.

Assertion failed

pawncc: /root/pawn/source/compiler/sc6.c:761: assemble: Assertion `numnatives==ntv_funcid' failed.

To recreate:

wget http://slice-vps.nl/pawn-assertion-fail.tar.gz
tar -xf pawn-assertion-fail.tar.gz
pawncc -\; -\( -d2 -i/path/to/include introspect_demo.pwn

#warning

There's "#error", I'd love a warning equivalent, but I realise that's not really a "fix".

Compiler calls wrong function

If you have an include file that defines a static function f and a script that includes that file and which also defines f (but not static this time), the compiler will call the wrong function.

// bug.inc
static f() {
    print("test");
}
// bug.pwn
#include <a_samp>
#include "bug"

f() {
    print("f");
}

main() {
    print("main");
    f();
}

In the script above main will recursively call itself instead of f, which will everntually result in a stack overflow.

Invalid/unsupported P-code file format

Using the latest version, every time I run the server with profiler plugin it shows Invalid/unsupported P-code file format

[11:22:55] [profiler] Error loading debug info: Invalid/unsupported P-code file format
[11:22:55] [profiler] Attached profiler to 'gamemodes/bcnr.amx' (no debug info)

Array of strings error

When I try to compile with this, the compiler outputs an error:

new floornames2[2][10] =
{
"abcde",
"defgh"
};
print(floornames2[0]);

No matter the array is global or not, it just gives an error at the line of the last element:

error 037: invalid string (possibly non-terminated string)

It can be easily fixed by putting the braces and colon right after the last element, but it isn't a very good practice to put that there I think.

Fails to build on Debian amd64

Also the instructions in the readme.txt don't accurately describe how to build from git - there are two sources directories (amx, compiler) which need separate cmake build directories

Various compiler errors. including:

pawn/source/amx/amx.c:493:5: error: enumerator value for β€˜assert_static__’ is not an integer constant

switch bug when calling certain functions on one line

Briefly,

case 4: { showPoliceRefill(playerid, .refillType = 1); return 1; }

works

but

case 4: showPoliceRefill(playerid, .refillType = 1);

crashes the compiler (it reports 26 errors with the latest test binary)

showPoliceRefill(playerid); works fine but showPoliceRefill(playerid, .refillType = 1); doesn't

It crashes with a default function argument

include <a_samp>

main()
{
new playerid, option = 1;
switch(option)
{
case 1: showPoliceRefill(playerid, .refillType = 1);
}
}

showPoliceRefill(playerid, refillType = 0)
{
switch(refillType)
{
case 0: functionex();
case 1: functionex();
}
}

functionex()
{
return 1;
}

EDIT: I can't get it recreated in a blank script, it happens in my large script. -.-

Backslashes and Linux

Windows Update broke my pawn compiler so I am switching everything to my Linux computer until I fixed that.

Now after compiling the pawn compiler and typing the command:
./pawncc main.pwn "-\(+ -;+ -O1 -d0"

It throws me fatal error 100: cannot read from file: "internal\y_natives".
Since all includes use ** rather than / I wonder if there is an easy solution to get Linux to support backslashes. Replacing them in every file is not really an option.

Sizeof for enums

I'm not certain how compiler handles enumerators, but sizeof doesn't bode well with hidden array sizes:

enum E_TEST {
    RandomValue,
    StringValue[64]
};

new Anything[MAX_PLAYERS][E_TEST];

//...
sizeof Anything[0][StringValue]; //1 - it makes sense for compiler, but not for average user

Latest version issues

Okay, firstly. I've been using the latest version and it's been perfect but lately I added a new function and it just won't allow me to use this function ANYWHERE. It's like if it has a function limit.

I removed all contents of the function and it's basically a return 1;

sendPlayerVerificationCode(playerid)
{
return 1;
}

then calling sendPlayerVerificationCode(playerid) anywhere crashes the script. Causing an 'access violation' error.

I HONESTLY can NOT recreate this outside my script.

I switched and to an old dropback version I use that only has line patches and 1 or 2 other things (11/03/2013 binary). The compiler then notified me about this error

"logoffDateStr = (logoffTime == 0) ? "(Player / Server) Crash / Exit" : realdate(logoffTime);"

which should actually be an error but the newer compiler was ignoring that fact that it was an error.

FIX -> (Wrapping the quotes with brackets) logoffDateStr = (logoffTime == 0) ? ("(Player / Server) Crash / Exit") : realdate(logoffTime);

I believe not using brackets around the quotes was a fix done in your updated pawn compiler right?

I honestly don't know what else to say about this, but this was my experience today.

Mutli-dimensional array initialisation completion

It would be good if this was supported:

new arr[10][20] = {{0, 1, ...}, ...};

Even better:

new arr[10][20] = {{0, 1, 2, ...}, {0, 2, 4, ...}, ...};

Supporting the same increment rules across both dimensions.

LSE as default?

What whould be, if you would merge LSE version to the master? This version goal is fix bugs, so there will be another bug fixed, and if someone use this complier, then now would need to use crashdetect LSE .

#undef INC

Can you see any reason why this line would suddenly break compilations? It seems that after I do that it can no longer find include files - is this a special symbol I didn't know about?

#pragma tabsize 0

PLEASE disable this - give an error or something (not "tabsize", that has uses, just "0").

__Pawn value

Could you alter "__Pawn" (#define VERSION_INT 0x0302) to something else so that we can detect in code when this version of the compiler is used please? I know 0x0303 and 0x0303 are taken by official compilers - maybe something outside their branch numbering like 0x030A (which would in their BCD system would be 0x0310 and so an impossible value otherwise).

Error with the newer versions and YSI.

E:\YSI 4.0\pawno\include\YSI..\YSI_Core\y_master.inc(133) : fatal error 111: user error: Did you do < YSI-Core/y_master > instead of the required < YSI-Core\y_master >?

With the 2 posted binaries (on github) I end up receiving this error however with the older version posted on the samp forums the compiler works fine.

Maximum array depth

Would it be possible to increase maximum array depth to 4<? Compiler flag would suffice. Example usage

#define MAX_QUESTIONS 128
#define MAX_ANSWERS 4

enum E_TYPE {
    TYPE_ONE,
    TYPE_TWO
}

static const
     QuestionAnswers[E_TYPE][MAX_QUESTIONS][MAX_ANSWERS][64]
;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.