Добро пожаловать на Pro Pawn - Портал о PAWN-скриптинге.
Показано с 1 по 2 из 2
  1. #1
    Аватар для red.inc
    Пользователь

    Статус
    Оффлайн
    Регистрация
    30.07.2019
    Адрес
    Беларусь, Витебск
    Сообщений
    23
    Репутация:
    0 ±

    Возм проблема с компилятором

    Приветствую. Занимаясь в свободное время пувнерством, решил устроить дичь.

    Мод компилируется без проблем, но при выводе в консоль, cellmax будет показываться в двух переменных.
    Но загруженность памяти у переменной pos_r будет меньше чем у pos_x[0]

    1. new pos_r = cellmax char;
    2. Header size: 172 bytes
    3. Code size: 92 bytes
    4. Data size: 4 bytes
    5. Stack/heap size: 16384 bytes; estimated max. usage=9 cells (36 bytes)
    6. Total requirements: 16652 bytes
    7.  
    8. new pos_x[1 char];
    9. pos_x[0] = cellmax; // Выбивает cellmax
    10. Header size: 172 bytes
    11. Code size: 128 bytes
    12. Data size: 4 bytes
    13. Stack/heap size: 16384 bytes; estimated max. usage=9 cells (36 bytes)
    14. Total requirements: 16688 bytes
    15.  
    16. new pos_x[1 char];
    17. pos_x{0} = cellmax; // Выбивает 255
    18. Header size: 172 bytes
    19. Code size: 140 bytes
    20. Data size: 4 bytes
    21. Stack/heap size: 16384 bytes; estimated max. usage=9 cells (36 bytes)
    22. Total requirements: 16700 bytes
    23.  
    24. new pos_x[1];
    25. pos_x{0} = cellmax; // Выбивает 255
    26. Header size: 172 bytes
    27. Code size: 140 bytes
    28. Data size: 4 bytes
    29. Stack/heap size: 16384 bytes; estimated max. usage=9 cells (36 bytes)
    30. Total requirements: 16700 bytes


    Продолжим:
    1. new pos_r[2 char];
    2. pos_r[0] = cellmax;
    3. pos_r[1] = cellmax; //error 032: array index out of bounds (variable "pos_r") (Выбивает на эту строку ошибку)
    4. // Посмотрев код выше, у нас схож действие было и не выбивало ошибку.


    1. new pos_r_1,
    2. pos_r_2;
    3. pos_r_1 = cellmax;
    4. pos_r_2 = cellmax;
    5. Header size: 172 bytes
    6. Code size: 148 bytes
    7. Data size: 4 bytes
    8. Stack/heap size: 16384 bytes; estimated max. usage=9 cells (36 bytes)
    9. Total requirements: 16708 bytes
    10.  
    11. new pos_r[2];
    12. pos_r{0} = cellmax;
    13. pos_r{1} = cellmax;
    14. Header size: 172 bytes
    15. Code size: 196 bytes
    16. Data size: 4 bytes
    17. Stack/heap size: 16384 bytes; estimated max. usage=9 cells (36 bytes)
    18. Total requirements: 16756 bytes
    19.  
    20. new pos_r[2 char];
    21. pos_r{0} = cellmax;
    22. pos_r{1} = cellmax;
    23. Header size: 172 bytes
    24. Code size: 196 bytes
    25. Data size: 4 bytes
    26. Stack/heap size: 16384 bytes; estimated max. usage=9 cells (36 bytes)
    27. Total requirements: 16756 bytes
    28.  
    29. new pos_r[2];
    30. pos_r[0] = cellmax;
    31. pos_r[1] = cellmax;
    32. Header size: 172 bytes
    33. Code size: 172 bytes
    34. Data size: 4 bytes
    35. Stack/heap size: 16384 bytes; estimated max. usage=9 cells (36 bytes)
    36. Total requirements: 16732 bytes


    Также ещё:
    1. new Float:pos_r[3 char];
    2.  
    3. printf("%02.f", pos_r{0});
    4. printf("%02.f", pos_r{1});
    5. printf("%02.f", pos_r{2}); // Не выбивает ошибки
    6.  
    7. Но при:
    8. new Float:pos_r[3 char];
    9.  
    10. printf("%02.f", pos_r[0]);
    11. printf("%02.f", pos_r[1]); //error 032: array index out of bounds (variable "pos_r")
    12. printf("%02.f", pos_r[2]); //error 032: array index out of bounds (variable "pos_r")


    Меня интересует - либо это баг компилятора, либо я - туту паровоз
    Последний раз редактировалось red.inc; 11.10.2022 в 01:17.

  2. #2
    Аватар для alonso
    Пользователь

    Статус
    Оффлайн
    Регистрация
    25.09.2017
    Сообщений
    11
    Репутация:
    0 ±
    Проблема в том, что ты не понимаешь как и для чего использовать оператор char
    Почитай это

 

 

Информация о теме

Пользователи, просматривающие эту тему

Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •