New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS High Sierra compile errors #58

Closed
richardloxley opened this Issue Apr 26, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@richardloxley

richardloxley commented Apr 26, 2018

I've been trying to compile on macOS High Sierra (10.13.4) and came across a few fatal compiler errors.

First error:

gcc -O2 -fno-strict-aliasing -std=gnu99 -Wall -Werror -I../../libdisk/include -MMD -MF ./.jv3.opic.d -m64 -fPIC -fvisibility=hidden -c -o jv3.opic jv3.c
jv3.c:478:28: error: comparison of constant 256 with expression of type 'uint8_t' (aka 'unsigned char') is always false
      [-Werror,-Wtautological-constant-out-of-range-compare]
        if (ti->nr_sectors >= 256)
            ~~~~~~~~~~~~~~ ^  ~~~

ti seems to be a track_info structure declared in libdisk/include/libdisk/disk.h, with the nr_sectors field declared as uint8_t, which therefore has a maximum value of 255.

To work around the error I commented out the check in jv3.c for nr_sectors >= 256 as it will never evaluate true. But I don't know what effect that has on the logic of the code!

Second error:

gcc -O2 -fno-strict-aliasing -std=gnu99 -Wall -Werror -I../../libdisk/include -MMD -MF ./.scp.opic.d -m64 -fPIC -fvisibility=hidden -c -o scp.opic scp.c
scp.c:232:49: error: implicit declaration of function 'htole64' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    ftr.creation_time = ftr.modification_time = htole64(time(NULL));
                                                ^

and the same error here:

gcc -O2 -fno-strict-aliasing -std=gnu99 -Wall -Werror -I../libdisk/include -MMD -MF ./.scp_dump.o.d -m64 -c -o scp_dump.o scp_dump.c
scp_dump.c:254:49: error: implicit declaration of function 'htole64' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    ftr.creation_time = ftr.modification_time = htole64(time(NULL));
                                                ^

I found a description of the same error here: tbuktu/libntru#14

It seems macOS doesn't have the function htole64().

I used the suggested workaround, and added the following lines near the top of libdisk/include/libdisk/util.h:

#ifdef __APPLE__
#include <libkern/OSByteOrder.h>
#define htole64(x) OSSwapHostToLittleInt64(x)
#endif

These changes allow a successful compile. Although I haven't tested all functionality with the changes!

@keirf

This comment has been minimized.

Owner

keirf commented May 2, 2018

Should work now. Reopen if not, especially the endian.h patch is untested and could be buggy.

@keirf keirf closed this May 2, 2018

@richardloxley

This comment has been minimized.

richardloxley commented May 3, 2018

It builds without error now - thanks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment