packjpg / packJPG

A compression program for further compressing JPEG image files
http://packjpg.encode.ru/
GNU Lesser General Public License v3.0
165 stars 26 forks source link

Erros when compiling on OSX #7

Closed subzerofun closed 7 years ago

subzerofun commented 7 years ago

From the source folder, i changed "Makefile" to "Makefile_other" and the "Makefile_osx" to "Makefile".

Then ran "make". These are the results:

$ make
c++ -c -o bitops.o bitops.cpp -I. -DUNIX -DDEV_BUILD -O3 -Wall -pedantic -funroll-loops -ffast-math -fomit-frame-pointer
In file included from bitops.cpp:6:
./bitops.h:185:7: warning: no newline at end of file [-Wnewline-eof]
#endif
      ^
bitops.cpp:249:54: error: expected '(' for function-style cast or type construction
                std::fill(data + cbyte + 1, data + dsize, unsigned char(0));
                                                          ~~~~~~~~ ^
bitops.cpp:287:55: error: expected '(' for function-style cast or type construction
                        std::fill(data + cbyte + 1, data + dsize, unsigned char(0));
                                                                  ~~~~~~~~ ^
bitops.cpp:595:8: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                case StreamType::kFile:
                     ^
bitops.cpp:599:8: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                case StreamType::kMemory:
                     ^
bitops.cpp:603:8: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                case StreamType::kStream:
                     ^
bitops.cpp:619:15: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        if ( srct == StreamType::kStream) {
                     ^
bitops.cpp:620:16: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                if ( mode == StreamMode::kWrite ) {
                             ^
bitops.cpp:630:14: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        if (srct == StreamType::kFile) {
                    ^
bitops.cpp:632:16: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                        if (mode == StreamMode::kWrite) fflush(fptr);
                                    ^
bitops.cpp:636:19: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        else if (mode == StreamMode::kRead) {
                         ^
bitops.cpp:652:15: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        if ( mode == StreamMode::kRead) {
                     ^
bitops.cpp:655:9: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                        case StreamType::kFile:
                             ^
bitops.cpp:659:9: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                        case StreamType::kMemory:
                             ^
bitops.cpp:660:9: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                        case StreamType::kStream:
                             ^
bitops.cpp:664:17: error: no member named 'make_unique' in namespace 'std'
                                mwrt = std::make_unique<abytewriter>( srcs );
                                       ~~~~~^
bitops.cpp:664:29: error: 'abytewriter' does not refer to a value
                                mwrt = std::make_unique<abytewriter>( srcs );
                                                        ^
./bitops.h:114:7: note: declared here
class abytewriter
      ^
bitops.cpp:669:10: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                mode = StreamMode::kWrite;
                       ^
bitops.cpp:674:9: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                        case StreamType::kFile:
                             ^
bitops.cpp:679:9: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                        case StreamType::kMemory:
                             ^
bitops.cpp:680:9: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                        case StreamType::kStream:
                             ^
bitops.cpp:684:17: error: no member named 'make_unique' in namespace 'std'
                                mrdr = std::make_unique<abytereader>( ( unsigned char* ) source, srcs );
                                       ~~~~~^
bitops.cpp:684:29: error: 'abytereader' does not refer to a value
                                mrdr = std::make_unique<abytereader>( ( unsigned char* ) source, srcs );
                                                        ^
./bitops.h:90:7: note: declared here
class abytereader
      ^
bitops.cpp:684:43: warning: expression result unused [-Wunused-value]
                                mrdr = std::make_unique<abytereader>( ( unsigned char* ) source, srcs );
                                                                      ^                  ~~~~~~
bitops.cpp:690:10: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                mode = StreamMode::kRead;
                       ^
bitops.cpp:700:19: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        return ( srct == StreamType::kFile) ? read_file( to, dtsize ) : read_mem( to, dtsize );
                         ^
bitops.cpp:704:18: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        return  srct == StreamType::kFile ? read_file_byte(to) : read_mem_byte(to);
                        ^
bitops.cpp:713:19: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        return ( srct == StreamType::kFile) ? write_file( from, dtsize ) : write_mem( from, dtsize );
                         ^
bitops.cpp:717:17: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        return srct == StreamType::kFile ? write_file_byte(byte) : write_mem_byte(byte);
                       ^
bitops.cpp:726:15: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        if ( srct == StreamType::kFile)
                     ^
bitops.cpp:739:15: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        if ( srct == StreamType::kFile)
                     ^
bitops.cpp:741:20: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        else if ( mode == StreamMode::kRead )
                          ^
bitops.cpp:757:15: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        if ( srct == StreamType::kFile)
                     ^
bitops.cpp:759:20: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        else if ( mode == StreamMode::kRead )
                          ^
bitops.cpp:775:15: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        if ( mode == StreamMode::kRead ) {
                     ^
bitops.cpp:776:16: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                if ( srct == StreamType::kFile) {
                             ^
bitops.cpp:799:15: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        if ( srct == StreamType::kMemory)
                     ^
bitops.cpp:800:20: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                return ( mode == StreamMode::kRead ) ? ( unsigned char* ) source : mwrt->getptr();
                                 ^
bitops.cpp:814:15: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        if ( srct == StreamType::kFile) {
                     ^
bitops.cpp:820:20: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        else if ( mode == StreamMode::kRead ) {
                          ^
bitops.cpp:840:15: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        if ( mode == StreamMode::kRead )
                     ^
bitops.cpp:841:20: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                return ( srct == StreamType::kFile) ? feof( fptr ) != 0 : mrdr->eof();
                                 ^
bitops.cpp:855:30: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        fptr = fopen( fn, ( mode == StreamMode::kRead ) ? "rb" : "wb" );
                                    ^
bitops.cpp:858:3: error: no member named 'setvbuf' in namespace 'std'; did you mean simply 'setvbuf'?
                std::setvbuf(fptr, file_buffer.data(), _IOFBF, file_buffer.capacity());
                ^~~~~~~~~~~~
                setvbuf
/usr/include/stdio.h:268:6: note: 'setvbuf' declared here
int      setvbuf(FILE * __restrict, char * __restrict, int, size_t);
         ^
bitops.cpp:868:15: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        if ( mode == StreamMode::kRead )
                     ^
bitops.cpp:869:15: error: no member named 'make_unique' in namespace 'std'
                mrdr = std::make_unique<abytereader>( ( unsigned char* ) source, srcs );
                       ~~~~~^
bitops.cpp:869:27: error: 'abytereader' does not refer to a value
                mrdr = std::make_unique<abytereader>( ( unsigned char* ) source, srcs );
                                        ^
./bitops.h:90:7: note: declared here
class abytereader
      ^
bitops.cpp:869:41: warning: expression result unused [-Wunused-value]
                mrdr = std::make_unique<abytereader>( ( unsigned char* ) source, srcs );
                                                      ^                  ~~~~~~
bitops.cpp:871:15: error: no member named 'make_unique' in namespace 'std'
                mwrt = std::make_unique<abytewriter>( srcs );
                       ~~~~~^
bitops.cpp:871:27: error: 'abytewriter' does not refer to a value
                mwrt = std::make_unique<abytewriter>( srcs );
                                        ^
./bitops.h:114:7: note: declared here
class abytewriter
      ^
bitops.cpp:881:15: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
        if ( mode == StreamMode::kRead ) {
                     ^
bitops.cpp:883:3: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
                auto strwrt = std::make_unique<abytewriter>( 0 );
                ^
bitops.cpp:883:22: error: no member named 'make_unique' in namespace 'std'
                auto strwrt = std::make_unique<abytewriter>( 0 );
                              ~~~~~^
bitops.cpp:883:34: error: 'abytewriter' does not refer to a value
                auto strwrt = std::make_unique<abytewriter>( 0 );
                                               ^
./bitops.h:114:7: note: declared here
class abytewriter
      ^
bitops.cpp:884:3: error: unknown type name 'constexpr'
                constexpr int buffer_capacity = 1024 * 1024;
                ^
bitops.cpp:884:13: error: expected unqualified-id
                constexpr int buffer_capacity = 1024 * 1024;
                          ^
bitops.cpp:885:39: error: unknown type name 'buffer_capacity'
    std::vector<unsigned char> buffer(buffer_capacity);
                                      ^
bitops.cpp:885:38: warning: parentheses were disambiguated as a function declaration [-Wvexing-parse]
    std::vector<unsigned char> buffer(buffer_capacity);
                                     ^~~~~~~~~~~~~~~~~
bitops.cpp:885:39: note: add a pair of parentheses to declare a variable
    std::vector<unsigned char> buffer(buffer_capacity);
                                      ^
                                      (
bitops.cpp:887:59: error: use of undeclared identifier 'buffer_capacity'
                int bytesRead = fread(buffer.data(), sizeof(buffer[0]), buffer_capacity, stdin);
                                                                        ^
bitops.cpp:890:56: error: use of undeclared identifier 'buffer_capacity'
                        bytesRead = fread(buffer.data(), sizeof(buffer[0]), buffer_capacity, stdin);
                                                                            ^
bitops.cpp:964:2: warning: no newline at end of file [-Wnewline-eof]
}
 ^
43 warnings and 18 errors generated.
make: *** [bitops.o] Error 1
TarVanimelde commented 7 years ago

In the OS X makefile class, add -std=c++14 to CFLAGS (-std=c++11 is insufficient because of std::make_unique, which was overlooked in C++11).

In bitops.cpp, replace the two instances of unsigned char(0) with static_cast<unsigned char>(0). In addition, replace #include <stdio.h> with #include <cstdio>. This gets packjpg to compile on macos for me using the macos makefile.

These compilation issues were caused by my submitting changes that compiled on MSVC without checking macos as well.