anjia0532 / lua-resty-maxminddb

A Lua library for reading MaxMind's Geolocation database
Apache License 2.0
97 stars 31 forks source link

Declaration specifier expected near 'ssize_t' #10

Closed demyanovs closed 6 years ago

demyanovs commented 6 years ago

Hi, When I include file "local geo = require 'resty.maxminddb'" I get an error: lua entry thread aborted: runtime error: .../resty_modules/lualib/resty/maxminddb.lua:115: declaration specifier expected near 'ssize_t' at line 73

It seems that should be typedef ssize_t in case if it is not declared. When I declare ssize_t as long or size_t, the error disappears.

My lua version: 5.1

anjia0532 commented 6 years ago

@demyanovs thanks for your report. it works for me(ubuntu).

paste your env plz.

os version: e.g. cat /etc/os-release openresty version: e.g. openresty -V maxmind/libmaxminddb version: e.g. mmdblookup --version

https://github.com/maxmind/libmaxminddb/blob/cc7b880263813fbb09b3e62b8b7f9e6e4444eb28/include/maxminddb.h#L37

#define ssize_t SSIZE_T

https://github.com/maxmind/libmaxminddb/blob/cc7b880263813fbb09b3e62b8b7f9e6e4444eb28/include/maxminddb.h#L177-L190

typedef struct MMDB_s {
    uint32_t flags;
    const char *filename;
    ssize_t file_size;
    const uint8_t *file_content;
    const uint8_t *data_section;
    uint32_t data_section_size;
    const uint8_t *metadata_section;
    uint32_t metadata_section_size;
    uint16_t full_record_byte_size;
    uint16_t depth;
    MMDB_ipv4_start_node_s ipv4_start_node;
    MMDB_metadata_s metadata;
} MMDB_s;
demyanovs commented 6 years ago

This error occurred when I ran lua without openresty, so the error is probably on my side.

anjia0532 commented 6 years ago

ok